I have encountered a very strange problem. I have some code that opens a second workbook, copies a sheet from the second workbook into the first workbook (where the VBA is), then closes the second workbook. It works fine if I run it from the code window, or by using View Macros. However, if I try to run it using an assigned Shortcut/Hot Key (CTRL+J ir CTRK+M), it will open the second workbook then hang. It won't do the copy or close the workbook. I have tried 4 different ways of doing the copy/paste (cells.select, selection.copy, ActiveSheet.copy, and the following code). All of them behave the same way - they work but not with the shortcut/hot key
SourcePath = "C:\Users\bkahn\Downloads\Duplicates\"
Filename = "500GB.csv"
SourceFile = SourcePath & Filename
Set SourceBook = Workbooks.Open(SourceFile)
SourceBook.Sheets(1).Copy After:=ThisWorkbook.Sheets(1)
SourceBook.Close SaveChanges:=False
ActiveSheet.Name = "2 line"
Why is there a difference when running this from a shortcut/hot key???
SourcePath = "C:\Users\bkahn\Downloads\Duplicates\"
Filename = "500GB.csv"
SourceFile = SourcePath & Filename
Set SourceBook = Workbooks.Open(SourceFile)
SourceBook.Sheets(1).Copy After:=ThisWorkbook.Sheets(1)
SourceBook.Close SaveChanges:=False
ActiveSheet.Name = "2 line"
Why is there a difference when running this from a shortcut/hot key???