G
Guest
A simple code opening 1st worksheet from user-identified spreadsheet - lines enclosed in <> can be retained or omitted
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
If fd.Show = -1 Then
FAOfficeFile = fd.SelectedItems(1)
<Workbooks.Open Filename:=FAOfficeFile, ReadOnly:=True>
Dim FAOfficeSheet As Worksheet
<Debug.Print Workbooks(FAOfficeFile).Worksheets.Count>
Set FAOfficeSheet = Workbooks(FAOfficeFile).Worksheets(1)
End If
gets 'Subscript out of range' error message at Set FAOfficeSheet = line <or Debug.Print line>. Could someone please suggest me the solution?
Thank you very much.
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
If fd.Show = -1 Then
FAOfficeFile = fd.SelectedItems(1)
<Workbooks.Open Filename:=FAOfficeFile, ReadOnly:=True>
Dim FAOfficeSheet As Worksheet
<Debug.Print Workbooks(FAOfficeFile).Worksheets.Count>
Set FAOfficeSheet = Workbooks(FAOfficeFile).Worksheets(1)
End If
gets 'Subscript out of range' error message at Set FAOfficeSheet = line <or Debug.Print line>. Could someone please suggest me the solution?
Thank you very much.