Multiple Macros Not Working

MyFirstMacro

New Member
Joined
Apr 26, 2011
Messages
3
I have several macros that I want to run with one macro. I have tried all of the following:

Sub Main()
Call Macro1
Call Macro2
Call Macro3
End Sub

Sub Main2()
Macro1
Macro2
Macro3
End Sub

Sub Main3()
Application.Run "'WorkbookName'!Macro1"
Application.Run "'WorkbookName'!Macro2"
Application.Run "'WorkbookName'!Macro3"
End Sub

Sub Main4()
If Range("$C$2").Value<>OldVal Then
Call Macro1
End If
If Range("$C$3").Value<>OldVal Then
Call Macro2
End If
If Range("$C$4").Value<>OldVal Then
Call Macro3
End If
End Sub
(The 4th one is supposed to run the macros only if their respective cell values change, I don't really care about this option but I'm just trying everything.)

In ALL 4 cases, the "Main" macro only runs Macro1 and then stops. I know that my submacros are right (Macro1, Macro2, Macro3) because I have tested them all separately. And, if I switch the order around in Main (to run Macro2, then Macro3, then Macro1) it runs Macro2 only and then stops.

How do I make it run all the macros???

As my username indicates, this is my first time ever writing macros from scratch. While I think I've learned a lot since yesterday afternoon, please assume I know nothing.

Thank you!!!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Just a guess:

Have you used the "End" statement in Macro1, 2, or 3?

You should post the code for one, or all of the macros that run by themselves.

Gary
 
Upvote 0
Here's an example:

Sub SERVICES3AND4()
If Cells(10, 3) = "Show" Then
Sheets("All (2)").Select
Columns("V:W").Select
Selection.EntireColumn.Hidden = False
ElseIf Cells(10, 3) = "Hide" Then
Sheets("All (2)").Select
Columns("V:W").Select
Selection.EntireColumn.Hidden = True
End If
End Sub

and another:

Sub Service2()
If Cells(9, 3) = "Show" And Cells(2, 3) = "3-11f" Then
Sheets("All (2)").Select
Columns("T:T").Select
Selection.EntireColumn.Hidden = False
Columns("U:U").Select
Selection.EntireColumn.Hidden = True
ElseIf Cells(9, 3) = "Show" And Cells(2, 3) = "4-11a" Then
Sheets("All (2)").Select
Columns("U:U").Select
Selection.EntireColumn.Hidden = False
Columns("T:T").Select
Selection.EntireColumn.Hidden = True
ElseIf Cells(9, 3) = "Show" And Cells(2, 3) = "side-by-side" Then
Sheets("All (2)").Select
Columns("T:U").Select
Selection.EntireColumn.Hidden = False
ElseIf Cells(9, 3) = "Hide" Then
Sheets("All (2)").Select
Columns("T:U").Select
Selection.EntireColumn.Hidden = True
End If
End Sub

Thanks!
 
Upvote 0
I don't see anything obvious. Maybe it has something to do with all the "Select" & "Selection" wherein you may be trying to select something that's hidden (though that should throw an error)

Try getting rid of the Select & Selections similar to this:

Code:
Sheets("All (2)").Select
Columns("T:T").Select
Selection.EntireColumn.Hidden = False

With something like this:

Code:
Sheets("All (2)").Range("T:T").EntireColumn.Hidden = False

Gary
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,112
Members
452,302
Latest member
TaMere

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