ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Retain values of combo box (https://www.excelbanter.com/excel-programming/324793-retain-values-combo-box.html)

gig

Retain values of combo box
 
I have a userform with several combo boxes so that the user can select
certain features. Upon clicking the "OK" button, the values are then
inserted into the appropriate ranges on the spreadsheet.

Is there a way that the values selected in the combo boxes can be
retained after the userform is either hidden or dismissed. I would like
the last values selected in case the user changes his mind and would
like to edit one or two selections without having to re-select all of
them. I tried just hiding the userform, but that did not work.

Thanks,

Greg


Jason Morin

Retain values of combo box
 
Why not just reload the combobox with the value in the
cell that corresponds to it?

UserForm1.ComboBox1.Value = Sheets("Sheet1").[A1].Value

HTH
Jason
Atlanta, GA

-----Original Message-----
I have a userform with several combo boxes so that the

user can select
certain features. Upon clicking the "OK" button, the

values are then
inserted into the appropriate ranges on the spreadsheet.

Is there a way that the values selected in the combo

boxes can be
retained after the userform is either hidden or

dismissed. I would like
the last values selected in case the user changes his

mind and would
like to edit one or two selections without having to re-

select all of
them. I tried just hiding the userform, but that did not

work.

Thanks,

Greg

.


keepITcool

Retain values of combo box
 

Have a look at the userforms collection...
problem is you can't easily access a member of that collection by name.

dim uf as object
'initialize the userform
'the initialize event of the form is triggered
set uf = userforms.add("userform1") 'or New userform1

'show the userform (activate event is triggered)
uf.show

'code returns here after form is hidden(deactivated) or
closed(terminated).

'if it is hidden the form remains in memory, and values are retained.

if userforms.count 0 then
userforms(1).show
else
msgbox "no loaded forms"
endif




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


gig wrote :

I have a userform with several combo boxes so that the user can select
certain features. Upon clicking the "OK" button, the values are then
inserted into the appropriate ranges on the spreadsheet.

Is there a way that the values selected in the combo boxes can be
retained after the userform is either hidden or dismissed. I would
like the last values selected in case the user changes his mind and
would like to edit one or two selections without having to re-select
all of them. I tried just hiding the userform, but that did not work.

Thanks,

Greg


gig

Retain values of combo box
 
This is the code I have:

Private Sub CommandButton1_Click()

Dim code_series As Range

Range("code_series") = CodeBox1

UserForm1.CodeBox1.Value = Sheets("Input Sheet").Range("z2").Value

UserForm1.Hide
End Sub

The funny thing is, on my work computer, the last value entered was
retained in the codebox, but on my home computer, it is not. Anyone see
anything wrong with this code?

Thanks,
Greg



All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com