I need a macro that will open a .DBF file to a tab in my worksheet. Is this possible? If so, can you show me the code needed and if not would you have any alternative suggestions? Thank you
I don't often work with Macros, but when I do, I always just use the "Record Macro" option. In this case, just start the Macro Recording, and Insert External Data. Then, just follow the wizard. This is a simple answer, of course, but the Macro code will vary depending on the location of the file to import.
irst open it to its own workbook, copy the data, close the dummy workbook.
Sub ABC()
Dim r1 as Range, r as Range, bk as Workbook
set r1 = Activesheet.range("A1")
set bk = workbooks.open("C:\Myfolder\Myfile.dbf")
set r = bk.worksheets(1).Range("A1").currentRegion
r.copy r1
bk.close SaveChanges:=False
end subThat is the way I have been doing it successfully in xl2003 and earlier for years. Support for Saving as DBF was dropped in xl2007 for sure but I believe it can still read a dbf file.
And more use: DBF Restore Toolbox fo restore your files simple, link here: http://www.dbf.restoretools.com/
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |