+ Reply to Thread
Results 1 to 6 of 6

VBA combobox UserForm_Initialize

Hybrid View

Hilton1982 VBA combobox... 12-01-2012, 04:12 AM
Norie How exactly are you... 12-01-2012, 04:29 AM
Hilton1982 Re: VBA combobox... 12-01-2012, 04:43 AM
Norie What's in your named ranges? 12-01-2012, 05:01 AM
Hilton1982 Re: VBA combobox... 12-01-2012, 05:14 AM
Hilton1982 Re: VBA combobox... 12-03-2012, 08:55 AM
  1. #1
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Lightbulb VBA combobox UserForm_Initialize

    HI

    I have two comboboxes with data validations link to dynamic named ranges.

    The first box is Months and the second is years.

    When i open the userform i want the comboboxes to display the current month and year I know it needs to be done on the Userform Initialize but i don't know how?

    Please assist?

    Thanks,

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    How exactly are you populating the comboboxes?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA combobox UserForm_Initialize

    Norie,

    See below code for Comboboxes

    Private Sub UserForm_Initialize()
      Dim cbM As Range
      Dim cbY As Range
      Dim ws As Worksheet
      Set ws = Worksheets("DataValidation")
    
    For Each cbM In ws.Range("monthlist")
      With Me.cbMonth
      .AddItem cbM.Value
      End With
    Next cbM
    
    For Each cbY In ws.Range("yearlist")
     With Me.cbYear
     .AddItem cbY.Value
     End With
    Next cbY
    
    Me.cbMonth.NumberFormat = "mmmm"
    End Sub

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

  5. #5
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA combobox UserForm_Initialize

    January - December and 2000-2025

  6. #6
    Forum Contributor
    Join Date
    02-22-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: VBA combobox UserForm_Initialize

    Norie,

    Any idee what to do with this?

+ 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