LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default 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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
Excel VBA Write to xls ? Adrian[_7_] Excel Programming 0 August 31st 04 02:23 PM
Loop,Compare,Write Michael168[_75_] Excel Programming 1 May 25th 04 06:41 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"