Please your help with the following:
- I need to call a macro which name is variable and is in cell C5 of Sheet1 of Workbook1.
- I need to run that macro in another workbook, let's say Workbook2.
Code that I have (in Workbook1) so far is:
Public Sub RS()
'Setting source worksheet and workbook where the macros are saved
Dim ws1 As Worksheet
Dim wb1 As Workbook
Set wb1 = ActiveWorkbook
Set ws1 = ActiveWorkbook.ActiveSheet
'Defining the cell that contains the name of the chosen macro to be run
Dim Macro1 As String
Macro1 = Range("C5").Value
'Selecting target workbook
Workbooks("Workbook2").Activate
ActiveSheet.Select
Dim ws2 As Worksheet
Dim wb2 As Workbook
Set wb2 = ActiveWorkbook
Set ws2 = ActiveWorkbook.ActiveSheet
'Running in Workbook2, the macro selected in workbook1
Call Macro1
End Sub
The problem is that Macro1
has not been recognized. I've been also trying with CallByName
function, and Application.Run Macro1
, but no luck either. Please tell me what I'm missing or what I should modify.