Reputation: 43
I want to be able to open up a second data source (workbook) and select the sheet within the second workbook which is equal to the name in a cell in my first workbook.
So far I have:
Dim src As Workbook
Dim src2 As Workbook
Dim shtno As String
Dim ws As Worksheet
Set src = ActiveWorkbook
shtno = Sheets("CONTROL").Range("G3").Value
Set ws = Sheets(shtno)
Workbooks.Open Filename:= 'file link
Set src2 = ActiveWorkbook
ws.Select
Where 'ws.Select' should select my sheet required. Where am I going wrong?
Thanks.
Upvotes: 0
Views: 577
Reputation: 96791
BigBen is correct.
You need to move the Set ws
statement down below the Workbooks.Open
statement then:
Set ws = src2.Sheets(shtno)
ws.Select
NOTE:
Open
the new workbook, it becomes the Active
workbookSelect
a worksheet on the Active
workbookUpvotes: 1