Solved

Loop until Cell is empty

Posted on 2004-10-11
3
267 Views
Last Modified: 2010-05-18
I am having trouble with a simple do/loop.  I want to loop until there is no value in the cell in column C.  Here is what I currently have:

Counter = 2
 
 Do
 Range("D" & Counter).Select
 Range("D" & Counter) = Range("Change!C9")
 Counter = Counter + 1
 Loop While ("C" & Counter) <> Null


This results in the first cell 'D2' being filled in but no other cells in row D.

I have tried Loop Until- this results in a never ending loop.  I have also tried
Loop While ("C" & Counter) <> ""- this results in a never ending loop.


Can anyone tell me what I am doing wrong.
0
Comment
Question by:slattbr
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Data-Man earned 125 total points
ID: 12281588
Change your loop to check for an empty string

While Range("C" & Counter) <>""


Mike
0
 

Author Comment

by:slattbr
ID: 12281704
Entered

 Do While Range("C" & Counter) <> ""
 
 Range("D" & Counter).Select
 Range("D" & Counter) = Range("Change!C9")
 Counter = Counter + 1
 Loop

and worked perfectly.

thanks mike
0
 
LVL 18

Expert Comment

by:Data-Man
ID: 12281765
you are welcome....Mike
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now