Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Load a Combo Box Object upon workbook open

I have a combo box which I use to load worksheet names into. However
have noticed that it does not load the names upon opening of th
spreadsheet. That is, when I open the spreadsheet, the box does no
include the entire list. This makes sense since I have used the clic
event to trigger the routine. However when I click on the combo bo
upon opening the spreadsheet it still does not load the list.

I have to go to the code and run it to load the comb box. At thi
point it is fine. Why is this?

Secondly is there a way that I can load the combo box upon opening th
spreadsheet? Teh code for the combo box is in the sheet module and i
a private sub. How do I trigger this private sub upon opening th
spreadsheet. I know I have to use a workbook_open event to tirgger it
But its a private sub routine. Can anyone help me with this?

Thanks


'This loads the ComboBox list
Private Sub SheetNameCmbBx_Click()
Dim Sh As Worksheet
Dim sVal As String

With SheetNameCmbBx
sVal = .Text
.Clear
For Each Sh In ActiveWorkbook.Sheets
If Sh.Name < "Inputs" Then
.AddItem Sh.Name
End If
Next
.Value = sVal
End With

End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Load a Combo Box Object upon workbook open

In a general sub

'This loads the ComboBox list
Sub LoadComboBox( bflag as Boolean)
Dim Sh As Worksheet
Dim sVal as String
With ThisWorkbook.Worksheets("Sheet1").ComboBox1
sVal = .Text
.Clear
For Each Sh In ActiveWorkbook.Sheets
If Sh.Name < "Inputs" Then
. AddItem Sh.Name
End If
Next
if bFlag then
.Value = sVal
Worksheets(.Value).Activate
End if
End With
End Sub

Then in your current click event
Private Sub Combobox1_Click()
LoadCombobox True
End Sub

Then in the ThisWorkbook module

Private Sub Workbook_Open()
Loadcombobobox False
End Sub

--
Regards,
Tom Ogilvy



"ExcelMonkey " wrote in message
...
I have a combo box which I use to load worksheet names into. However I
have noticed that it does not load the names upon opening of the
spreadsheet. That is, when I open the spreadsheet, the box does not
include the entire list. This makes sense since I have used the click
event to trigger the routine. However when I click on the combo box
upon opening the spreadsheet it still does not load the list.

I have to go to the code and run it to load the comb box. At this
point it is fine. Why is this?

Secondly is there a way that I can load the combo box upon opening the
spreadsheet? Teh code for the combo box is in the sheet module and is
a private sub. How do I trigger this private sub upon opening the
spreadsheet. I know I have to use a workbook_open event to tirgger it.
But its a private sub routine. Can anyone help me with this?

Thanks


'This loads the ComboBox list
Private Sub SheetNameCmbBx_Click()
Dim Sh As Worksheet
Dim sVal As String

With SheetNameCmbBx
sVal = .Text
Clear
For Each Sh In ActiveWorkbook.Sheets
If Sh.Name < "Inputs" Then
AddItem Sh.Name
End If
Next
Value = sVal
End With

End Sub


---
Message posted from http://www.ExcelForum.com/



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
Could not load object Excelfan Excel Discussion (Misc queries) 2 November 22nd 08 03:43 PM
Could not load an object because it is not available on this machi Mike K Excel Discussion (Misc queries) 1 August 20th 06 06:46 AM
Could not load an object because it is not available on this machine H.A. de Wilde Excel Discussion (Misc queries) 1 June 26th 06 12:11 PM
Could not load an object wayne Excel Programming 3 September 1st 04 08:27 PM
Could Not Load an Object vish tumu Excel Programming 3 November 19th 03 10:52 AM


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

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"