My macro keyboard shortcut does not run the macro properly. But selecting the macro manually does.
From an already opened workbook, I am trying to open another workbook (Template.xlsx) and copy a sheet from the first workbook into this newly opened workbook. It works when I open the “view macros” menu in excel and click “run”. But when I use the keyboard shortcut, it only opens the second workbook and does not copy my sheet into it. Any idea why this is and how to get my keyboard shortcut to work?
Sub MergeTest3()
'
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
Dim CompWrksht As Workbook
Set CompWrksht = ActiveWorkbook
Dim wb As Workbook
Dim template As String
template = "V:NickValidation WorksheetsECCMaui Wild FiresTemplate.xlsx"
Set wb = Workbooks.Open(template)
CompWrksht.Activate
Sheets("Sheet1").Select
Sheets("Sheet1").Move Before:=Workbooks("Template.xlsx").Sheets(1)
'CompWrksht.Sheets("Sheet1").Select
'CompWrksht.Sheets("Sheet1").Move Before:=Workbooks("Template.xlsx").Sheets(1)
End Sub
user25473841 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1