Loading combo box list

  • Thread starter Thread starter Greg Snidow
  • Start date Start date
G

Greg Snidow

Greetings. I am loading a combo box list on the initialize event with code I
found here, and it works perfectly.

For Each sh In ActiveWorkbook.Sheets
Me.ComboBox1.AddItem sh.Name
Next

However, there are two sheets, the last two that I don't want to show up in
the list. I can't find an easy way to keep these two sheets out. Any ideas?
Thank you.

Greg
 
Ok, that was easy.

For Each sh In ActiveWorkbook.Sheets
If sh.Name <> "BDMS" And sh.Name <> "HELD" Then
Me.ComboBox1.AddItem sh.Name
End If
Next
 
If it's always the last 2 sheets you don't want then you could use this which
would be a tade shorter. Hope this helps! If so, let me know, click "YES"
below.

For wks = 1 To Sheets.Count - 2
Me.ComboBox1.AddItem Sheets(wks).Name
Next wks
 
Thanks for the tip. That is actually what I was trying to do, but I was
making it much more complicated than you have done.
 
Back
Top