Hi,
I would like to know how to open any excel files from any directory and extract specific columns and copy it to an Access table. Can I use wildcards in the vba code? This is the code I used in Excel to open any excel files but the code doesn't work when I tried using it on Access:
Sub btnOpenExcel
Dim vFile As Variant
'Showing Excel Open Dialog Form
vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _
"*.xl*", 1, "Select Excel File", "Open", False)
'If Cancel then exit
If TypeName(vFile) = "Boolean" Then
Exit Sub
End If
'Open selected file
Workbooks.Open vFile
End Sub
I would like to know how to open any excel files from any directory and extract specific columns and copy it to an Access table. Can I use wildcards in the vba code? This is the code I used in Excel to open any excel files but the code doesn't work when I tried using it on Access:
Sub btnOpenExcel
Dim vFile As Variant
'Showing Excel Open Dialog Form
vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _
"*.xl*", 1, "Select Excel File", "Open", False)
'If Cancel then exit
If TypeName(vFile) = "Boolean" Then
Exit Sub
End If
'Open selected file
Workbooks.Open vFile
End Sub
Last edited: