Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
For..Next loop error | Excel Programming | |||
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error | Excel Programming | |||
Error in loop | Excel Programming | |||
loop error | Excel Programming | |||
loop error | Excel Programming |