Retain values of combo box

  • Thread starter Thread starter gig
  • Start date Start date
G

gig

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
 
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
 
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 :
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top