Dear All,
I am trying to open a file dialogue box in Excel but keep getting " runtime Error 9 - subscript out of range" on the line in bold. Any thoughts ? Thanks
Kaps
I am trying to open a file dialogue box in Excel but keep getting " runtime Error 9 - subscript out of range" on the line in bold. Any thoughts ? Thanks
Kaps
Rich (BB code):
Public Sub Get_source_data()
Dim file_name As String
Dim FilterIndex As Integer
Dim filter As String
Dim fd2 As FileDialog
'open the Sage CSV file
Set fd2 = Application.FileDialog(msoFileDialogFilePicker)
With fd2
.AllowMultiSelect = False
' .InitialFileName = local_path
.Title = "Please select price file"
.Filters.Add "Text Files", "*.csv", 2
.FilterIndex = 2
If .Show = -1 Then file_name = .SelectedItems(1)
End With
If Len(file_name) > 0 Then
'open the workbook
Workbooks.Open file_name
Set price_workbook = ActiveWorkbook
With ActiveSheet
.Name = "Sheet1"
End With
Sheets.Add
With ActiveSheet
.Name = "graph"
End With
End If
End Sub