Default for Dates in User Form

  • Thread starter Thread starter Ligaya
  • Start date Start date
L

Ligaya

I was just wondering if anybody could help me in making the
last date entry on an input box as the last date to show-up
when a user invoke the userform.

I have a pull down menu on the dates and an option for the
user to type the dates. However, when the user try to
change the date again after the user exit the userform, the
default is not the last date the user entered.

Much obliged for your help.

Ligaya
 
Hi Ligaya

You must save the choice somewhere. An external text file, in the registry, or in a cell
on a perhaps hiden sheet -here in Sheet3 A1:

Private Sub UserForm_Initialize()
'dummy setup:
Dim D As Date
For D = Date - 15 To Date + 15
ComboBox1.AddItem D
Next
'set last default:
ComboBox1.Text = Sheets(3).Cells(1, 1).Value
End Sub

Private Sub CommandButton1_Click() 'OK button
'save this as default:
Sheets(3).Cells(1, 1).NumberFormat = "@"
Sheets(3).Cells(1, 1).Value = ComboBox1.Text
'rest of actions here:
' -- and finally:
Unload Me
End Sub
 
Back
Top