Default Combo Box To Todays Date

  • Good Morning folks


    Ive got a form with 2 combo boxes - one with the days of the month, and one with the months of the year.
    Im trying to have the combo boxes defautl to todays date when the form is shown. Ive tried the following but never worked:


    * paste "=now()" into cell A1 on the workbook open event (the cell is custom formatted to "dd")
    * paste =now()" into cell A2 on the workbook open event (the cell is custom formatted to "mmmm")
    * have combobox1 value = cell A1 on initialize
    * have combobox2 value = cell A2 on initialize


    Obviously because of the excel date formats this threw up crazy numbers. Does anyone have any sugestions? (my ideas are always a long way for a short cut, but imaginitive!)


    Thanks
    Jamie

  • Re: Default Combo Box To Todays Date


    Code
    ComboBox1.Value=Format(Date,"dd/mm/yy")

    [hr]*[/hr] Auto Merged Post;[dl]*[/dl]BTW, you MAY want this is the Change Event of the Combo;

    Code
    Private Sub ComboBox1_Change()
      If IsDate(ComboBox1) Then
           ComboBox1 = Format(ComboBox1, "dd/mm/yy")
      End If
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!