Hello
I want to create a report that pulls in data from a shared workbook containing multiple worksheets.
Unfortunately I'm stumbling fairly early as I can't set the variable to refer back to the original file containing the data once it has been opened. Basically I need to be able to toggle between two workbooks but the name of one will vary every time it is used to create the report. Code is as follows:
Sub ReportMacro()
Dim fNameAndPath As Variant
Dim THISWB As Workbook
'Step 1
fNameAndPath = Application.GetOpenFilename(FileFilter:="Excel Files (*.XLS), *.XLS", Title:="Select File To Be Opened")
If fNameAndPath = False Then Exit Sub
Workbooks.Open Filename:=fNameAndPath
Set THISWB = ActiveWorkbook
On Error Resume Next
Dim WB As Workbook
WB = "FSD BAS report test.xls"
'
Windows(THISWB).Activate
Sheets("Core Input").Select
Range("I8").Select
Application.CutCopyMode = False
Selection.Copy
Windows(WB).Activate
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(THISWB).Select
Works OK to this point but doesn't go back to file opened at step 1 above but stays in current as this is now deemed to be the active workbook
Thanks in anticipation
Bookmarks