Hi
I want to get some data from a workbook, but it could be saved anywhere, under any name and the sheet I want might not always have the same name.
So I've built a userform with a combobox, in the hope that people can choose the worksheet they want.
Any ideas what's wrong with this code?
Thanks
Chris
I want to get some data from a workbook, but it could be saved anywhere, under any name and the sheet I want might not always have the same name.
So I've built a userform with a combobox, in the hope that people can choose the worksheet they want.
Any ideas what's wrong with this code?
Code:
FileName = Application.GetOpenFilename("Microsoft Excel Spreadsheet (*.xlsx),*.xlsx," & _
"Microsoft Excel Macro-Enabled Workbook (*.xlsm),*.xlsm," & _
"Microsoft Excel 97-2003 Spreadsheet (*.xls),*.xls," & _
"View All Files (*.*),*.*,", 1)
OldFileName = FileName
Workbooks.Open FileName
FileName = Right(FileName, Len(FileName) - InStrRev(FileName, "\"))
Load frmSelectWorksheet
For Each WSheet In FileName
frmSelectWorksheet.cmbWorkSheet.AddItem Worksheet.Name
Next
Thanks
Chris