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

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
886
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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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
 
Upvote 0
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
 
Upvote 0
Solution
Thank you all very much, I went with JGordon11's solution without the message box. Much appreciated, Thank you all again! ? ?
 
Upvote 0
Thanks for the feedback,
Regards, JLG
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,159
Members
448,948
Latest member
spamiki

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