Consulting

Results 1 to 3 of 3

Thread: Solved: A Simple(?) ComboBox Query

  1. #1
    VBAX Regular
    Joined
    Jun 2005
    Posts
    11
    Location

    Solved: A Simple(?) ComboBox Query

    I've been pulling my hair out since lunch with what I'm sure is a simple problem.

    I've got a ComboBox on a user form. When the form initialises I want it to be populated with the current date in the format "Mon-YY" along with the following 11 months (ie: 12 months in total).

    I'm sure I've done this before but can't for the life of me remember how I did.

    Can one of you save my sanity?

    Martin

  2. #2
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Hi Martin,

    Sure, but who needs sanity? [vba]Private Sub UserForm_Initialize()
    Dim i As Long
    For i = 0 To 11
    ComboBox1.AddItem Format(DateSerial(Year(Date), Month(Date) + i, 1), "mmm-yy")
    Next
    End Sub[/vba]
    Matt

  3. #3
    VBAX Regular
    Joined
    Jun 2005
    Posts
    11
    Location
    Matt

    Many thanks - that's a drink I owe you.

    What little sanity I have left is preserved - and the girls in the office don't have to watch a grown man crying any more!!

    Martin

Posting Permissions

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