Hi - I'm new to VBA programming and am trying to write a macro in Excel. I have a named cell (LR_FileName) where the user will input the name of the file. The macro will then activate that file (should already be open) and select and copy cells from that file to the file with the macro. However, when I run the code, I receive the following error:
Run-time error '1004':
Method 'Range' of object' _Global' failed
Here is the section of code that it is tripping up on:
Code:
Sub CDSS_Data_Fill_2_ColB()
Windows(Range("CDSS_Name").Value).Activate
Application.ScreenUpdating = False
Range("G2").Select
Selection.Copy
Windows(Range("LR_FileName").Value).Activate
Range("B6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
When I run the debug, the line Windows(Range("LR_FileName").Value).Activate is highlighted.
If I change the code to just activate a file name instead of a referenced Named cell, I get the same error but on the next line (Range("B6").Select
Thanks for any help!