• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Can we record a Macro that takes care of these steps?

GN0001

Member
Imagine we have 8 categories and we have a workbook with 11 sheets. Each sheet is assigned to a category. The sheet 1 is the coversheet. Sheet 2 and 3 has all categories to the end. I need to record a Macro that deletes the word master from the name of the file and add the name of one of the categories to it. For example if my file name is: string master, the name of master should be replaced by name of one category.


2- All other name of categories should be taken off except one category from line 5, 7, 15, 17, 125, 126 from the coversheet. For example: if the name file is string & Category A. Only category A should be kept in coversheet.


3- We delete all the sheets and we keep the first three plus two other sheets that have the acronym of the same category.


I have a few other steps included as well that I don’t mention, since I think it is not necessary.

Does anybody know that recording a Macro can take care of these operations?

Your help is greatly appreciated.
 
Guity

You can't record aa macro which will do this in 1 pass.

But you can record a number of the steps and then put some VBA code around them to make it all work


Can you post a file with more details
 
Dear Hui,


I can't post the file. As you say, if recording several Macro can take care of the work, I will do that. Don't you think, instead of recording several Macros we can do the task with combination of less Macros and adding several manual steps?


Regards,

Guity
 
Guity

You are getting confused between a Macro and VBA

A macro is a recording of a few steps in VBA, it just repeats what you do but uses VBA to do it. eg: Select Row 7 and delete it. Next time you run the macro it will select row 7 and delete it again. Macro's can't include logic, flow control or use variables.


VBA is a full programming language which allows you to add flow control, conditional branching and variables to the code

ie: In VBA you program a series of steps and include logic telling VBA when to do things

eg: If C7 = 10 delete Row 10


Recording macros is great for getting the syntax or format of the statements correct.

So often I will want to know how a line in VBA should be structured, I will record a Macro which say selects a Chart and makes a line Red. Then I will copy that line of code and use it in my VBA code.
 
Hui,


Wow....what a good solution

I want to record a Macro tomorrow at work. I need this Macro to be available from other files. Do I need to save the file in Personnel.xlsx? What is the name of the file and where is it? What should I save in this folder? Do I need to save the Excel workbook itself in this folder?

Do I need to save only VBA code in this folder? Would you please say the steps?

This would be appreciated and I am in need of that....

Regards,

Guity
 
Guity

When you record a macro

complete the Store Macro In: drop down and change it to Personnal Macro Workbook
 
Back
Top