Reputation: 1
I am getting Run time error 9
Sub Conway()
Dim aRng As Range
Dim Data As Range, c As Collection
Dim v As String, i As Long, ary
Set c = New Collection
Path = "D:\InTransit DR Report\"
RawFile = Application.GetOpenFilename(, , "Please Select InTransit Raw WorkBook:")
Application.DisplayAlerts = False
If RawFile = "False" Then
MsgBox "Please select appropriate Final Output file", vbCritical, "Nike InTransit DR Automation"
Exit Sub
Else
Workbooks.Open RawFile, True, False
Application.Wait (10)
Application.Visible = False
Application.Visible = True
Application.WindowState = xlMaximized
ActiveWindow.WindowState = xlMaximized
End If
Sheets("In-Transit").Select 'Getting error here
Upvotes: 0
Views: 249
Reputation: 96753
We are dealing with two workbooks:
Once wb2 has been opened, it becomes the Active
workbook and the line:
Sheets("In-Transit").Select
will only work if that sheet is in wb2. If the sheet is in the original workbook (wb1), that workbook must be re-activated beforre the sheet can be Selected
. Also make sure that there are no extra spaces in the sheetname.
Upvotes: 1