Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default default value for combo box

Hello,
I've got 3 combo boxes on the same worksheet, returning
values entered on an other worksheet.
I would like to:
- set up a default value for the 3 combo boxes (blank)
- when one combo box is selected, reset values to default
for the 2 others

Thanks for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default default value for combo box

When do you want the comboboxes to be set to the default value -
Whenver the sheet is entered?
Only when the workbook is opened?

Use the Workbook_Open event would be one approach

Private Sub Workbook_Open()
With ThisWorkbook.worksheets("Sheet1")
.OleObjects("Combobox1").Object.ListIndex = -1
.OleObjects("Combobox2").Object.ListIndex = -1
.OleObjects("Combobox3").Object.ListIndex = -1
End With
End Sub

In the sheet code for the comboboxes

Private Sub Combobox1_Click()
OnlyOne ComboBox1, Me
End Sub

Private Sub Combobox2_Click()
OnlyOne ComboBox2, Me
End Sub

Private Sub Combobox3_Click()
OnlyOne ComboBox3, Me
End Sub



In a general Module
Public Sub OnlyOne(cbox As MSForms.ComboBox, sh As Worksheet)
Dim cb1 As MSForms.ComboBox
Dim cb2 As MSForms.ComboBox
Dim cb3 As MSForms.ComboBox
Set cb1 = sh.OLEObjects("Combobox1").Object
Set cb2 = sh.OLEObjects("Combobox2").Object
Set cb3 = sh.OLEObjects("Combobox3").Object
If cbox.ListIndex = -1 Then Exit Sub
Select Case LCase(cbox.Name)
Case "combobox1"
cb2.ListIndex = -1
cb3.ListIndex = -1
Case "combobox2"
cb1.ListIndex = -1
cb3.ListIndex = -1
Case "combobox3"
cb1.ListIndex = -1
cb2.ListIndex = -1
End Select
End Sub

--
Regards,
Tom Ogilvy



"Laurent Payan" wrote in message
...
Hello,
I've got 3 combo boxes on the same worksheet, returning
values entered on an other worksheet.
I would like to:
- set up a default value for the 3 combo boxes (blank)
- when one combo box is selected, reset values to default
for the 2 others

Thanks for your help.



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
Combo box default value Newbie800 Excel Discussion (Misc queries) 0 February 1st 10 01:10 PM
combo reference on another combo box for picking address etc. kbjin Excel Worksheet Functions 1 December 8th 06 03:29 PM
Default value in Combo box Paul987 Excel Discussion (Misc queries) 4 March 23rd 06 06:19 PM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 1 February 16th 05 02:05 AM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 0 February 15th 05 07:45 PM


All times are GMT +1. The time now is 12:26 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"