Can you import only the 2nd Sheet from Excel to Access using VBA -
can import 2nd sheet excel access using vba?! did googling on , couldn't find definitive answer.
here code i'm trying working.
strpathfile = fil objxl.visible = true set wkb = objxl.workbooks.open(strpathfile) each wks in wkb.worksheets if wkb.wks = wkb.sheet(2) docmd.transferspreadsheet acimport, acspreadsheettypeexcel9, strtable, strpathfile, blnhasfieldnames end if next
i'm trying import data bunch of excel files, second sheet in file, each sheet has different name.
as turns out, missing 2 things.
1) wks.index = 2
2) needthissheet = wks.name & "!"
here code snippit.
strpathfile = fil objxl.visible = true set wkb = objxl.workbooks.open(strpathfile) each wks in wkb.worksheets if wks.index = 2 needthissheet = wks.name & "!" docmd.transferspreadsheet acimport, acspreadsheettypeexcel9, strtable, strpathfile, blnhasfieldnames, needthissheet end if next wkb.close
thanks everyone!!
Comments
Post a Comment