Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Loop without Do error

Hello. Can anyone figure out why I am getting a Loop without Do error with
the below code? I am trying to populate a listbox with ONLY visible sheets.
Thanks!

Private Sub Worksheet_Activate()
Dim intsheets As Integer
Dim ws As Worksheet

ListBox1.MultiSelect = fmMultiSelectMulti
ListBox1.Clear

intsheets = 1

Do While intsheets < (Sheets.Count + 1)
If ws.Visible = True Then
ListBox1.AddItem Worksheets(intsheets).Name
Else
intsheets = intsheets + 1
Loop
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Loop without Do error

missing

End If


--
Tim Williams
Palo Alto, CA


"Steph" wrote in message ...
Hello. Can anyone figure out why I am getting a Loop without Do error with
the below code? I am trying to populate a listbox with ONLY visible sheets.
Thanks!

Private Sub Worksheet_Activate()
Dim intsheets As Integer
Dim ws As Worksheet

ListBox1.MultiSelect = fmMultiSelectMulti
ListBox1.Clear

intsheets = 1

Do While intsheets < (Sheets.Count + 1)
If ws.Visible = True Then
ListBox1.AddItem Worksheets(intsheets).Name
Else
intsheets = intsheets + 1
Loop
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Loop without Do error

You have a block "If" statement without an "End If". Excel is taking the
"Loop" as being inside the "If" statement with no "Do" inside the same "If"
statement. You need an "End If" before the "Loop" line. HTH Otto
"Steph" wrote in message
...
Hello. Can anyone figure out why I am getting a Loop without Do error
with the below code? I am trying to populate a listbox with ONLY visible
sheets. Thanks!

Private Sub Worksheet_Activate()
Dim intsheets As Integer
Dim ws As Worksheet

ListBox1.MultiSelect = fmMultiSelectMulti
ListBox1.Clear

intsheets = 1

Do While intsheets < (Sheets.Count + 1)
If ws.Visible = True Then
ListBox1.AddItem Worksheets(intsheets).Name
Else
intsheets = intsheets + 1
Loop
End Sub



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
For..Next loop error Ian_Limbo Excel Programming 14 December 14th 04 05:49 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Error in loop Daniel Bonallack[_2_] Excel Programming 2 November 19th 03 07:10 PM
loop error Sam Excel Programming 1 September 18th 03 03:09 PM
loop error Sam Excel Programming 0 September 18th 03 02:19 PM


All times are GMT +1. The time now is 05:20 PM.

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"