Results 1 to 7 of 7

Pre-Setting ComboBox Value

Threaded View

  1. #1
    Registered User
    Join Date
    06-25-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    34

    Pre-Setting ComboBox Value

    I have a UserForm which asks for a date with three separate ComboBox (month, day, year).

    I have initialized them as follows:

    Public Sub UserForm_Initialize()
    
    ' Add months to the ComboBox
    With Month
        For x = 1 To 12
            .AddItem (x)
        Next x
    End With
    
    ' Add days to the combo box
    With Day
        For y = 1 To 31
            .AddItem (y)
        Next y
    End With
    
    ' Add Years to the combo box
    With Year
        For y = 2010 To 2015
            .AddItem (y)
        Next y
    End With
    
    Shift.AddItem "Day" ' Add day shift
    Shift.AddItem "Night" ' Add night shift
    
    'Month.Value = Month(Date)
    'Day.Value = Day(Date)
    'Year.Value = Year(Date)
    
    End Sub
    What I am trying to do is pre-set them with the current date. I have attempted it with the commented out code at the bottom which gives an error "Type Mismatch"

    Any ideas on how I can successfully pre-set them?

    Thanks!

    Also posted at: http://www.mrexcel.com/forum/showthr...15#post2382015
    Last edited by nbuk; 07-20-2010 at 11:22 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1