Do Until ? I think

  • Thread starter Thread starter Wally Steadman
  • Start date Start date
W

Wally Steadman

Hi all,
Just learning to do VBA in Excel and by making a macro I
can see what type of code to use, but I have been stumped
on this one. I am a sheet that lists values in the first
column and I have a macro that loops through those values
doing a DO UNTIL Loop but where it is messing up is I have
been putting the last entry in the column as "ENDFILE" so
I DO UNITL ENDFILE is reached, but that is inefficient as
it still adds a blank worksheet for the ENDFILE Row but
not sure how to get it to stop without adding that sheet
and I am sure it is simple

Example
1
A Dave
B Steve
C Paul
D Dan
E Tina
F Debbie
G Tanya
H ENDFILE

What I am doing is having the code add worksheets to the
workbook and each sheet is named Dave, Steve, Paul etc...
But tomorrow I can have More or Less names so I need it to
loop until the first blank cell I guess but don't know how
to identify that cell. Any help would be appreciated.

Wally Steadman
 
Dim rng as Range
set rng = Cells(1,1)
do until isempty(rng)
worksheets.Add(After:=worksheets( _
worksheets.count)).Name = rng.Value
set rng = rng.offset(1,0)
Loop

Remove ENDFILE from the last cell.
 
Thanks Tom, appreciate the help.
-----Original Message-----
Dim rng as Range
set rng = Cells(1,1)
do until isempty(rng)
worksheets.Add(After:=worksheets( _
worksheets.count)).Name = rng.Value
set rng = rng.offset(1,0)
Loop

Remove ENDFILE from the last cell.

--
Regards,
Tom Ogilvy




.
 
Back
Top