VBA help: Running a Macro within a Macro based on a cell value

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
742
Office Version
  1. 365
Platform
  1. Windows
I need another Macro to be called based on a cell value in a particular workbook (yes the workbook will be open)

What I need is as follows:

IF in workbook: Manager Review Meeting Dashboard, Sheet: Dashboard, Cell: W8

= “Second”

Call Macro “Second”

IF in workbook: Manager Review Meeting Dashboard, Sheet: Dashboard, Cell: W8

= “Third”

Call Macro “Third”

IF in workbook: Manager Review Meeting Dashboard, Sheet: Dashboard, Cell: W8

= “First” OR BLANK

Call Macro “First”

Below is an idea of how the code runs before I need it to take a break and call another macro to run:

VBA Code:
‘Macro code etc etc

Range("Y1").Select

ActiveCell.FormulaR1C1 = "Falls between prev yr selected range"

Range("Y2").Select



‘REQUIRE RUNNING ANOTHER MACRO BASED ON CONDITIONS (AS PER ABOVE)



‘Continue running remaining macro

Sheets("Data").Select

Workbooks.Open etc etc

Any help would be greatly appreciated

Thank you! :)
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
VBA Code:
With Workbooks("Manager Review Meeting Dashboard").Sheets("Dashboard")
    If .Range("W8") = "" Then
        First
    ElseIf .Range("W8") = "Second" Then
        Second
    ElseIf .Range("W8") = "Third" Then
        Third
    End If
End With
 

JGordon11

Active Member
Joined
Jan 18, 2021
Messages
285
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Something like this maybe. It would probably be safer to name W8 in case you nee to move it or add rows or columns before it. If you name it FST then just change Range("W8") to Range("FST").
Rich (BB code):
Sub CallingMacro()

    MsgBox "Running Calling Macro"
   
    Select Case Workbooks("Manager Review Meeting Dashboard").Sheets("Dashboard").Range("W8").Value
        Case "Second"
            Second
        Case "Third"
            Third
        Case Else
            First
    End Select
    
    MsgBox "Calling Macro Complete"
    
End Sub

Sub First()
    MsgBox "Running First"
End Sub

Sub Second()
    MsgBox "Running Second"
End Sub
Sub Third()
    MsgBox "Running Third"
End Sub
 
Solution

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
742
Office Version
  1. 365
Platform
  1. Windows
Thank you all very much, I went with JGordon11's solution without the message box. Much appreciated, Thank you all again! 😊 😊
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
Thanks for the feedback,
Regards, JLG
 

Forum statistics

Threads
1,147,451
Messages
5,741,191
Members
423,647
Latest member
lyanndominique

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
Top