Excel automation

S

SHIPP

How do I determine the row number that I am on in Excel so that I can use
that row number in a loop?

Here is my current code which works just fine from Access.

' Open the Excel
Set objXL = CreateObject("Excel.Application")
Set xlBook1 = objXL.Workbooks.Open(Me.strImportPath)
objXL.Visible = True
With objXL
.Range("D1").Select
dtePO = .ActiveCell.Value
.Range("D3").Select
strPO = Str(.ActiveCell.Value)

.Range("A6").Select
.Selection.End(xlDown).Select
intCnt = 0
While intCnt < 20
rs.AddNew
rs("CustomerID") = 1
rs("PONO") = strPO
rs("PODate") = dtePO
rs("ItemID") = .ActiveCell.Value
.ActiveCell.Offset(0, 4).Select
rs("Qty") = .ActiveCell.Value
.ActiveCell.Offset(0, 2).Select
rs("UPC") = .ActiveCell.Value
rs.Update
.ActiveCell.Offset(-1, -6).Select
intCnt = intCnt + 1
Wend

End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top