View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Can you default a value in a CombBox?

Private Sub Workbook_Open()
With Worksheets(1)
If .Range("A1").Value < "" Then
.OLEObjects("ComboBox1").Object.Value = .Range("A1").Value
End If
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"TimN" wrote in message
...
Bob,

The short answer is Yes, it is in the list, but here is the situation.

I have a user form with a ComboBox that contains a list of all employees.
The user will select an employee from the list in the comobox and that

value
goes to cell A1 and other calculations occur. When the user is done, they
save the file as the selected employee's name. Later, the user will open
that saved file to make additions to it.
When the saved file is re-opened the combobox is sitting empty waiting on
the user to select the employee. I would like it to default in the
employee's name from the saved file since that file will always be

dedicated
to that employee. However, if the user goes back to the original template
(not a saved employee file) the combobox would be empty since there is

name
to default in, a blank combobox is approrpriate.




"Bob Phillips" wrote:

If the value is in the combo list just set the Value property to that

cell
value

ComboBox1.Value = Range("A1").Value

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"TimN" wrote in message
...
Is it possible to have a ComboBox with a default value based on say

Cell
A1
which if there is a name, the name defaults in, otherwise it is blank.

All
while still having the ability to use the dropdown list in the

ComboBox?

Thanks for your ideas.