View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Hansen Rick Hansen is offline
external usenet poster
 
Posts: 104
Default how to update Listbox of sheetnames if user changes sheetnames?

Hi Troy,

Add the following code to your UserForm_Initialize(). Everytime you open the
userform the listbox will updated with current worksheet names. Enjoy...

Rick

Option Explicit
Private Sub UserForm_Initialize()

Dim wsht As Worksheet

Me.ListBox1.Clear '' clear old ListBox
'' reintialize listbox
For Each wsht In Worksheets
Me.ListBox1.AddItem wsht.Name
Next wsht

End Sub



"tr00per" wrote in message
oups.com...
Hello everyone. Thanks for all your help in the past, and hopefully
someone will be able to get me pointed in the right direction with this
problem too.

I have a userform containing a listbox. the listbox is loaded with the
sheetnames of the workbook. How can I know when/if the user changes
the worksheet names, so that I will then know to update the values of
the listbox so that the listbox always contains the current list of
sheetnames?

Any help is greatly appreciated.

Thanks in advance, and happy programming!

Troy