Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
don don is offline
external usenet poster
 
Posts: 21
Default ComboBox start condition

I have a ComboBox on a UserForm giving a single column
choice of 5 user options generated from an Array. All
works fine. I would like the ComboBox to display the last
user selected value (which is stored in a named cell on
the worksheet,) when the program is started. I have written
ComboBox1.Value = Range("Somename").Value in the
"Private Sub UserForm_Initialize()" module but although
the program reads this, it has no effect.
Any help would be much appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ComboBox start condition

that should work, but if it doesn't

Private Sub Userform_Initialize()
Dim i as Long
for i = 0 to Combobox1.ListCount - 1
if instr(1,combobox1.List(i),Trim(Range("Somename"),v bTextCompare) then
combobox1.ListIndex = i
exit for
end if
Next
End Sub

Make sure your Initialize event is named as above regardless of the name of
the userform. Make sure it is in the userform module.

This also assumes that the List has already been initialized.

--
Regards,
Tom Ogilvy


"Don" wrote in message
...
I have a ComboBox on a UserForm giving a single column
choice of 5 user options generated from an Array. All
works fine. I would like the ComboBox to display the last
user selected value (which is stored in a named cell on
the worksheet,) when the program is started. I have written
ComboBox1.Value = Range("Somename").Value in the
"Private Sub UserForm_Initialize()" module but although
the program reads this, it has no effect.
Any help would be much appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
don don is offline
external usenet poster
 
Posts: 21
Default ComboBox start condition

Very many thanks Tom. Your solution works fine. I didn't
realise that you have to pull what you want out of the
ComboBox's list. Thought you could just put it straight in
from my Range("Somename"). Anyway, thanks again
Regards Don


-----Original Message-----
that should work, but if it doesn't

Private Sub Userform_Initialize()
Dim i as Long
for i = 0 to Combobox1.ListCount - 1
if instr(1,combobox1.List(i),Trim(Range

("Somename"),vbTextCompare) then
combobox1.ListIndex = i
exit for
end if
Next
End Sub

Make sure your Initialize event is named as above

regardless of the name of
the userform. Make sure it is in the userform module.

This also assumes that the List has already been

initialized.

--
Regards,
Tom Ogilvy


"Don" wrote in

message
...
I have a ComboBox on a UserForm giving a single column
choice of 5 user options generated from an Array. All
works fine. I would like the ComboBox to display the

last
user selected value (which is stored in a named cell on
the worksheet,) when the program is started. I have

written
ComboBox1.Value = Range("Somename").Value in the
"Private Sub UserForm_Initialize()" module but although
the program reads this, it has no effect.
Any help would be much appreciated.



.

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
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
start:1 and start:2 - how did i get 2 copies? LuvHaleiwa Excel Discussion (Misc queries) 1 December 21st 07 09:14 PM
lookup with multiple condition, but one condition to satisfy is en Eddy Stan Excel Worksheet Functions 2 October 27th 07 02:06 PM
OT :Start your own online business today !start making dollars [email protected] Excel Discussion (Misc queries) 0 May 6th 06 09:29 PM
Start spreadsheet with WinXP start Gordon Gradwell Excel Worksheet Functions 1 July 13th 05 11:35 AM


All times are GMT +1. The time now is 11:34 PM.

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"