Zab Trader
New Member
- Joined
- Feb 19, 2019
- Messages
- 5
This is beginning part of a macro that worked fine in a xlsm file.
To share the code saved it as a Personal Macro.
Problem is it fails at the 3rd line. Line1 worked fine, so sheet is there.
Run-time Error 9 subscript out of range error
Thanks, Zab
To share the code saved it as a Personal Macro.
Problem is it fails at the 3rd line. Line1 worked fine, so sheet is there.
Run-time Error 9 subscript out of range error
Code:
ActiveSheet.Name = "Not Quoted"
Dim wsSummary As Worksheet
Set wsSummary = ThisWorkbook.Sheets("Not Quoted")
Dim NewWB As Workbook
ChDrive "C:"
NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xlsx), *.xlsx", Title:="Select Data File That Supplier Provided")
If NewFN = False Then
MsgBox "Exiting Program For No File Selected"
Exit Sub
Else
Set NewWB = Workbooks.Open(Filename:=NewFN, ReadOnly:=True)
End If
Dim wsData As Worksheet
Set wsData = NewWB.Sheets("Sheet1")
LastRow1 = NewWB.Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
wsSummary.Range("A3:A3" & LastRow1).Value = wsData.Range("F3:F3" & LastRow1).Value
wsSummary.Range("B3:B3" & LastRow1).Value = wsData.Range("D3:D3" & LastRow1).Value
NewWB.Close