#1   Report Post  
Posted to microsoft.public.excel.programming
RJ RJ is offline
external usenet poster
 
Posts: 40
Default UserForm

I have the following code for when a userform loads. The userform is opened
using a command button in the workbook. The code is supposed to take all of
the worksheets names in the workbook and load them into a combo box for the
user to select from. The first name in the combo box should be the fourth
sheet and every subsequesnt sheet in the in workbook thereafter. When I first
open the workbook the code seems to work fine...however if I add new
worksheets and open the userform using the command button the new worksheets
are not being displayed in the combobox. Any ideas? I have tried to clear the
array and clear the combo box up initialize, but neither attempt has worked.

Private Sub UserForm_Initialize()
Dim sheetnames() As String
Dim totalsheets As Integer
Dim sheet As Worksheet
Dim i As Integer

totalsheets = ActiveWorkbook.Worksheets.Count - 3
ReDim sheetnames(totalsheets)

For i = 1 To totalsheets
sheetnames(i - 1) = ActiveWorkbook.Worksheets(i + 3).Name
Next

For i = 0 To totalsheets - 1
UserForm1.ComboBox1.AddItem sheetnames(i)
Next
End Sub

Thanks!!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default UserForm

You have a response at your other post.

RJ wrote:

I have the following code for when a userform loads. The userform is opened
using a command button in the workbook. The code is supposed to take all of
the worksheets names in the workbook and load them into a combo box for the
user to select from. The first name in the combo box should be the fourth
sheet and every subsequesnt sheet in the in workbook thereafter. When I first
open the workbook the code seems to work fine...however if I add new
worksheets and open the userform using the command button the new worksheets
are not being displayed in the combobox. Any ideas? I have tried to clear the
array and clear the combo box up initialize, but neither attempt has worked.

Private Sub UserForm_Initialize()
Dim sheetnames() As String
Dim totalsheets As Integer
Dim sheet As Worksheet
Dim i As Integer

totalsheets = ActiveWorkbook.Worksheets.Count - 3
ReDim sheetnames(totalsheets)

For i = 1 To totalsheets
sheetnames(i - 1) = ActiveWorkbook.Worksheets(i + 3).Name
Next

For i = 0 To totalsheets - 1
UserForm1.ComboBox1.AddItem sheetnames(i)
Next
End Sub

Thanks!!


--

Dave Peterson
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
Is there an easy Copy/Paste of a Userform ? (Entire Userform Including tx & cbx's) Corey Excel Programming 2 January 9th 07 01:01 PM
Userform to enter values and shown in same userform in list helmekki[_104_] Excel Programming 0 November 19th 05 03:23 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM
Access from add_in userform to main template userform.... Ajit Excel Programming 1 November 18th 04 05:15 PM


All times are GMT +1. The time now is 09:06 AM.

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"