Avatar of drtopserv
drtopserv
Flag for Israel asked on

Import excel files xls/xlsx/xlsm into access by vba code

Hi,
I`d like to import excel extentionS into table in access i have the code to do that.
the issue is that the code import the file/files with row contain null/empty value.
how may i discard importing empty rows?
In out way : if all the row is empty/null don`t import it .
Microsoft AccessDatabasesMicrosoft Office

Avatar of undefined
Last Comment
drtopserv

8/22/2022 - Mon
ukerandi

DoCmd.TransferSpreadsheet  acImport,acSpreadsheetTypeExcel12Xml, "Table1", "C:\Winxp\testing.xls", True, "" 
ukerandi

DoCmd.TransferSpreadsheet  acImport,"", "Table1", "C:\Winxp\testing.xls", True, "" 
drtopserv

ASKER
Yes it works :} thnxx:}
but what that  "" Means? in the range
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ukerandi

after acImport is Excel spreadsheet type, for example Excel 2003 or Excel 2010 or xml type
like
acSpreadsheetTypeExcel12Xml
acSpreadsheetTypeExcel12

after true "" is Range
A1:B3



ukerandi

more explain Range

A string expression that's a valid range of cells or the name of a range in the spreadsheet. This argument applies only to importing. Leave this argument blank to import the entire spreadsheet. When you export to a spreadsheet, you must leave this argument blank. If you enter a range, the export will fail.
drtopserv

ASKER
still can`t follow,
if i came to import the excel without writing "" i`ll get all the sheet include empty rows.
which parameter that tell that u wanna import only cells cotains data without empty rows?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
ukerandi

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
drtopserv

ASKER
does ur code work work in access vba?
ukerandi

no, you need to run first run above macro in Excel
Norie

There is no setting that will stop blank rows/records being imported.

Why not run a delete query after the import to delete the blank rows/records?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ukerandi

before run need to enabled security settings
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
drtopserv

ASKER
thnx,ur code help me out "}