Running simultaneously multiple worksheet Macros from one Macro

Jan Kalop

Active Member
Joined
Aug 3, 2012
Messages
389
I have six identical Macros for six worksheets, from MonDBS to SatDBS

VBA Code:
Sub MonDBS_Last_ROW()
Range("C700").End(xlUp).Select
End Sub
VBA Code:

VBA Code:
Sub TueDBS_Last_ROW()
Range("C700").End(xlUp).Select
End Sub
VBA Code:

VBA Code:
Sub WedDBS_Last_ROW()
Range("C700").End(xlUp).Select
End Sub
VBA Code:

VBA Code:
Sub ThuDBS_Last_ROW()
Range("C700").End(xlUp).Select
End Sub
VBA Code:

VBA Code:
Sub FriDBS_Last_ROW()
Range("C700").End(xlUp).Select
End Sub
VBA Code:

VBA Code:
Sub SatDBS_Last_ROW()
Range("C700").End(xlUp).Select
End Sub
VBA Code:

All Macros works on each worksheet, but I would like to have one Macro for sample on worksheet MonDBS which would run all the Macros accross all of those six worksheet simultaneously
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You only need one macro.
If you want code to select a cell, you need to select the sheet as well.
VBA Code:
    Dim sh As Worksheet

    For Each sh In Sheets
        With sh
            .Select
            .Cells(.Rows.Count, "C").End(xlUp).Select
        End With
    Next
 
Upvote 0
You only need one macro.
If you want code to select a cell, you need to select the sheet as well.
VBA Code:
    Dim sh As Worksheet

    For Each sh In Sheets
        With sh
            .Select
            .Cells(.Rows.Count, "C").End(xlUp).Select
        End With
    Next
Thankyou for your help, but I can not make it working
 
Upvote 0
Thankyou for your help, but I can not make it working
I think it should be somehow restricted only to those worksheets mentioned in the post, because in this case I have another 10 worksheets in that workbook, and even I make it working it keeps looping and looping for very long time.
 
Upvote 0
You only need one macro.
If you want code to select a cell, you need to select the sheet as well.
VBA Code:
    Dim sh As Worksheet

    For Each sh In Sheets
        With sh
            .Select
            .Cells(.Rows.Count, "C").End(xlUp).Select
        End With
    Next
I think it should be somehow restricted only to those worksheets mentioned in the post, because in this case I have another 10 worksheets in that workbook, and even I make it working it keeps looping and looping for very long time.
 
Upvote 0
You can create an array of sheet names, then loop through them.

VBA Code:
    Dim ws, i
    'create the array of sheet names
    ws = Array("www", "Sheet2", "Sheet8", "Sheet6", "Sheet4", "Sheet3")
    
    For i = LBound(ws) To UBound(ws)
    
        With Worksheets(ws(i))
            .Select
            .Cells(.Rows.Count, "C").End(xlUp).Select
        End With
    Next i
 
Upvote 0
Solution
You can create an array of sheet names, then loop through them.

VBA Code:
    Dim ws, i
    'create the array of sheet names
    ws = Array("www", "Sheet2", "Sheet8", "Sheet6", "Sheet4", "Sheet3")
   
    For i = LBound(ws) To UBound(ws)
   
        With Worksheets(ws(i))
            .Select
            .Cells(.Rows.Count, "C").End(xlUp).Select
        End With
    Next i
Many thanks, now everything works as I wished and thank you very much for your help
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,840
Members
449,193
Latest member
MikeVol

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