Hi,
I have to extract certain cells of an excel file and update an access database. I have already found code in this form which does exactly that. The problem is, this code has the path of the file built into it. I want the ability to be able to browse and choose the file. I have tried out a piece of code that browses for a file and displays the number of files chosen. Could anyone help me on how to get the path of the file to give it as input to the extracting portion of the code?
The code which browses and gets the number of files chosen is:
The portion of the code that uses the file path (For extracting cells) is:
I am new to VBA and any help would be greatly appreciated
Thank you in advance.
I have to extract certain cells of an excel file and update an access database. I have already found code in this form which does exactly that. The problem is, this code has the path of the file built into it. I want the ability to be able to browse and choose the file. I have tried out a piece of code that browses for a file and displays the number of files chosen. Could anyone help me on how to get the path of the file to give it as input to the extracting portion of the code?
The code which browses and gets the number of files chosen is:
Code:
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
f.Show
MsgBox "file choosen = " & f.SelectedItems.Count
The portion of the code that uses the file path (For extracting cells) is:
Code:
Set xlw = xlx.Workbooks.Open("C:\Filename.xls", , True) '
Set xls = xlw.Worksheets("WorksheetName")
I am new to VBA and any help would be greatly appreciated
