How to write a vba loop for Excel
Paul:
I have the following code for an Excel
worksheet, it works on the first try but it
fails on the second time. It returns an error
saying "Object variable or With block variable
not set". Thanks
.Range("A6").Select
If Not rs1.BOF Then
rs1.MoveFirst
Do While Not rs1.EOF
strPurchaseOrder =
rs1!PurchaseOrder 'Assign
Purchase Order to Excel
ActiveCell.Offset(1,
0).Select..............................it fails
here.
The message you get means that you try to work
with an object variable that
has no contents / context yet.
In your example I would guess that you probably
has got no selection in your
sheet or that the ActiveCell is not existing. To
me these two seems to be
conflicting, either you have ONE acitve cell or
you have a selection. Or am
I completely wrong here?
Nevertheless, check all variables for their
contents in your function call
to see which one is not set yet.
--
( )---cucchiaino
|