Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Need help with do while loop

I'm using ADO to retrieve records from an access table and store them in an
excel sheet. The following line of code populates all records at once.

Worksheets("sheet2").Range("A1").CopyFromRecordset rst

Can someone help me in writing a do while loop that will populate one record
at a time. I want the record to only write to the same cell each time. Yes,
the record will write over the previous one until it reaches the last record.
Thanks.




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Need help with do while loop

Markantesp

Do While Not rs.EOF
Range("A1").Value = rs.Fields(0).Value
Range("B1").Value = rs.Fields(1).Value
etc..
rs.MoveNext
Loop

Where rs is the variable that holds your recordset.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Markantesp wrote:
I'm using ADO to retrieve records from an access table and store them
in an excel sheet. The following line of code populates all records
at once.

Worksheets("sheet2").Range("A1").CopyFromRecordset rst

Can someone help me in writing a do while loop that will populate one
record at a time. I want the record to only write to the same cell
each time. Yes, the record will write over the previous one until it
reaches the last record. Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Need help with do while loop

Hi,

Try something like this...


With RS

--
Message posted via http://www.officekb.com
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Need help with do while loop

Hi,

Try something like this...


With RS

--
Message posted via http://www.officekb.com
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Need help with do while loop

oops....
sorry!


What I meant was try this..


With RS
If not .BOF then .MoveFirst

--
Message posted via http://www.officekb.com


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Need help with do while loop

thankyou!

"Dick Kusleika" wrote:

Markantesp

Do While Not rs.EOF
Range("A1").Value = rs.Fields(0).Value
Range("B1").Value = rs.Fields(1).Value
etc..
rs.MoveNext
Loop

Where rs is the variable that holds your recordset.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Markantesp wrote:
I'm using ADO to retrieve records from an access table and store them
in an excel sheet. The following line of code populates all records
at once.

Worksheets("sheet2").Range("A1").CopyFromRecordset rst

Can someone help me in writing a do while loop that will populate one
record at a time. I want the record to only write to the same cell
each time. Yes, the record will write over the previous one until it
reaches the last record. Thanks.




Reply
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
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
How do I create a For loop within a For loop? Linking to specific cells in pivot table Excel Programming 2 January 24th 05 08:05 AM
For/Loop skipping one value in loop only Matt Jensen Excel Programming 6 January 8th 05 12:03 PM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 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 09:49 AM.

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

About Us

"It's about Microsoft Excel"