Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Do Until ? I think

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Do Until ? I think

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

Wally Steadman wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Do Until ? I think

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

Wally Steadman

wrote in message
...
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



.

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



All times are GMT +1. The time now is 11:17 PM.

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"