Simultaneously run Macro on Multiple worksheet? Please Help!

jassyphee

New Member
Joined
Jan 8, 2014
Messages
16
I'm having the hardest time trying to figure out how to run the macro on multiple sheets simultaneously. Therefore, the data should update for all 4 sheets, but that doesn't happen. Instead only the first worksheet gets update. I know the issue has to do with the first couple of lines. Here's the code I've been using:
Code:
Sub AutoNumber()    Worksheets("Cap. Rec.").Select
    Worksheets("Cap. Disb.").Select False
    Worksheets("Rev. Rec.").Select False
    Worksheets("Rev. Disb.").Select False
    
    Dim bottomrow As Long
   
    bottomrow = Cells(Rows.Count, "B").End(xlUp).row
    
    Range("A5").Formula = "=A4+1"
    Range("'Cap. Disb.'!A4").Formula = "=INDEX('Cap. Rec.'!A5:A1048576, COUNTA('Cap. Rec.'!A5:A1048576), 1)"
    Range("'Rev. Rec.'!A4").Formula = "=INDEX('Cap. Disb.'!A5:A1048576, COUNTA('Cap. Disb.'!A5:A1048576), 1)"
    Range("'Rev. Disb.'!A4").Formula = "=INDEX('Rev. Rec.'!A5:A1048576, COUNTA('Rev. Rec.'!A5:A1048576), 1)"
    
    Application.ScreenUpdating = False
    Range("A5").AutoFill Destination:=Range("A5:A" & bottomrow), Type:=xlFillDefault
    Application.ScreenUpdating = True
    
   
End Sub

Thank you for the help! GREATLY APPRECIATE IT.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You can't run a macro on multiple sheets simultaneously but you can run them sequentially. You've given the code you've tried but not really indicated what you want it to do. Can you supply a brief statement of intent as to what you want to achieve?
 
Upvote 0
Alright, what i'm trying to do is have sequential numbering in 4 of my worksheets, so that as soon as the numbering ends in column A of sheet1, next worksheet will continue the count/numbering.
You can't run a macro on multiple sheets simultaneously but you can run them sequentially. You've given the code you've tried but not really indicated what you want it to do. Can you supply a brief statement of intent as to what you want to achieve?
 
Upvote 0
Try the following:

Code:
Sub AutoNumber2()
    Application.ScreenUpdating = False
    Sheets("Cap. Rec.").Range("A4").Value = 1
    Sheets("Cap. Disb.").Range("A4").Formula = "=MAX('Cap. Rec.'!A5:A" & Rows.Count & ")+1"
    Sheets("Rev. Rec.").Range("A4").Formula = "=MAX('Cap. Disb.'!A5:A" & Rows.Count & ")+1"
    Sheets("Rev. Disb.").Range("A4").Formula = "=MAX('Rev. Rec.'!A5:A" & Rows.Count & ")+1"
    For Each shtName In Array("Cap. Rec.", "Cap. Disb.", "Rev. Rec.", "Rev. Disb.")
        With Sheets(shtName)
            .Range("A5").Formula = "=A4+1"
            .Range("A5").AutoFill Destination:=.Range("A5:A" & .Cells(.Rows.Count, "B").End(xlUp).Row)
        End With
    Next
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,087
Messages
6,128,740
Members
449,466
Latest member
Peter Juhnke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top