By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,835 Members | 1,119 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,835 IT Pros & Developers. It's quick & easy.

Excel Import VBA question

P: n/a
Hi,
my first time doing an excel import. It works. Can close off when I
get to the last field with data, but would like it to keep checking to
see if there is any more data (user has a blank space between data
rows), not just exit
Have tried several things, but not sure how to get back to the top and
loop to the top until the last line is reached.
What I have so far is:

For i = i_from To i_to
i = i + 1
If (excel_ws.Cells(i, 2).Value = "") Then
***how to get back to the top???? (currently is
'goto close_excel' and saves data, exits)
Else
DoCmd.RunSQL "INSERT INTO ...
End If
Next i

May 21 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Try this,

iLastRowNr = Selection.Cells.Find(What:="*", After:=[A1],
SearchDirection:=xlPrevious).Row
For i = i_from ToiLastRowNr

Filip
"stevenrec" <st****@stevenrec.comwrote in message
news:11*********************@x18g2000prd.googlegro ups.com...
Hi,
my first time doing an excel import. It works. Can close off when I
get to the last field with data, but would like it to keep checking to
see if there is any more data (user has a blank space between data
rows), not just exit
Have tried several things, but not sure how to get back to the top and
loop to the top until the last line is reached.
What I have so far is:

For i = i_from To i_to
i = i + 1
If (excel_ws.Cells(i, 2).Value = "") Then
***how to get back to the top???? (currently is
'goto close_excel' and saves data, exits)
Else
DoCmd.RunSQL "INSERT INTO ...
End If
Next i

May 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.