+ Reply to Thread
Results 1 to 4 of 4

userform combobox to show current month

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-09-2009
    Location
    Chicago, US
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    188

    userform combobox to show current month

    hi guys. i have a user form which has "start date" and "end date"

    both have one combobox, which lists months Jan to Dec..and then there are two text boxes where a user inputs a day (ex: 14) and a year (ex: 2009)

    Here is the code:

    Private Sub UserForm_Initialize()
    
    With cbxEndMonth
    .AddItem "Jan"
    .AddItem "Feb"
    .AddItem "Mar"
    .AddItem "Apr"
    .AddItem "May"
    .AddItem "Jun"
    .AddItem "Jul"
    .AddItem "Aug"
    .AddItem "Sep"
    .AddItem "Oct"
    .AddItem "Nov"
    .AddItem "Dec"
    End With
    
    cbxEndMonth.ListIndex = 0
    
    With cbxStartMonth
    .AddItem "Jan"
    .AddItem "Feb"
    .AddItem "Mar"
    .AddItem "Apr"
    .AddItem "May"
    .AddItem "Jun"
    .AddItem "Jul"
    .AddItem "Aug"
    .AddItem "Sep"
    .AddItem "Oct"
    .AddItem "Nov"
    .AddItem "Dec"
    End With
    
    cbxStartMonth.ListIndex = 0
    
    End Sub
    I would like to have the current date show up in the "end date". So I would like the cbxEndMonth checkbox to show the current month, and the end day ("txtEndDay") and end year ("txtEndYear") show the current day and year.

    So when a open a user form, it'll display nothing in the first (start date) inputs and have the current

    Feb (in checkbox) 24 (in text box ) and 2010 (in other text box) in the End Date section.



    Is that possible? Thank you all in advance!
    Last edited by losmi8; 02-25-2010 at 01:42 AM.

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: userform combobox to show current month

    Yes it is.
    Somewhere towards the end of the initialize event, put this in.
    cbxEndMonth.Value = Month(now)
    txtEndDay.Value = Day(now)
    txtEndYear.Value = Year(now)

  3. #3
    Registered User
    Join Date
    07-16-2010
    Location
    singapore
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: userform combobox to show current month

    any Sample

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: userform combobox to show current month

    How are you populating the comboboxes for day and year?
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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