• 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.

Generalizing Macros to all Worksheet

Chachu

New Member
Hi Guys
I have written a Macro using VBA in excel but all my commands were in Sheet1, so it only works on Sheet 1. File is attached. Go on Sheet 1 and run Macro names "RunAll".
I will copy data from Sheet "Audi" to "sheet1", matching the criteria in Cell A2 (of sheet1). It subtotals, copy and past special at the bottom of the existing data (scroll down to see that). Runs some formulas to give some results.
Please assist to make it general that it should run this macro on each sheet, using the criteria in A2 of everysheet and pull out data from there.
I have atleast 15 sheet at the moment and it is increasing.
Let me know if you want more information on this.
cheers :)
 

Attachments

  • Test-Macro 5.xlsm
    773.6 KB · Views: 5
Great job man. It is working brilliant :)
However, since I wrote it using manual commands, it is not very flexible. I am having some troubles, and I have attached these issues in word file attached. Also I am attaching the near final final that i need to present this month. I am already appreciating your help.

many thanks
 

Attachments

  • Test-Macro 5-8.xlsm
    535.2 KB · Views: 3
  • Macro Issues.docx
    66.5 KB · Views: 1
1) Unfortunately you will have to define the sheet names you don't want as part of your calculation.
2) You might need to add error handling mechanism like "On Error GoTo" and tell it to skip the sheet & go to next sheet
3) Related to 1
4) Write in a piece of code like:
Code:
IF IsEmpty(Range("A2")) Then
     ws.Next.Select
Else
     'Carry on my code
EndIf
 
Back
Top