Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50070

Application.Run Error When Using A Variable to Run Macro In Another Sheet

$
0
0
Hello!

I am new to VBA and having trouble using a variable to run a macro in another sheet. The macro I'm trying to run is called "bride". It copies a range in a sheet that I want to paste in my active sheet. When I try to run the code below, I get a syntax error for the "Application.Run" command and I haven't been able to figure out what I'm doing wrong after much trial and error! I also tried defining the "copyWB" variable as a workbook, but couldn't get that to work either.

Thanks for any help!

Code:


Sub copypaste_master()

Dim copyWB As String
copyWB = "Schedule Engine_v0.29_with macro_V3.xlsm"
Dim pasteWB As Workbook
Set pasteWB = ThisWorkbook

Workbooks(copyWB).Activate
Application.Run copyWB&"!bride"

pasteWB.Activate
Worksheets("Sheet1").Activate
ActiveSheet.Range("D5").Select
ActiveSheet.Paste

End Sub


Viewing all articles
Browse latest Browse all 50070

Trending Articles