Results 1 to 5 of 5

Excel 2007 sort combobox

Threaded View

  1. #1
    Registered User
    Join Date
    05-19-2013
    Location
    Thailand
    MS-Off Ver
    Excel 2007
    Posts
    7

    Post Excel 2007 sort combobox

    Hi everyone, this is my first post, and I am NOT a proficient VBA programmer. For some of you this might be easy, but after 2 days, it is driving me nuts.

    I have a combobox which is populated with folder names,, the folder names are month and year. eg Apr 2013, this works fine, no problems. The problem is, in the combobox list the months are in alphabetical order, I would like to sort them so that they run from Jan 2013 to Dec 2013.

    All help appreciated, but PLEASE keep it relevant.

    My code:

    Private Sub CommandButton1_Click()
    Dim name


    Me.ComboBox2.Clear
    For Each name In ListDirectory(Path:="C:\Users\Laurie\Documents\Pai Hotel\Log\Daily Log - Year 2013\", AttrInclude:=vbDirectory, AttrExclude:=vbSystem Or vbHidden)
    If name Like "Jan*" Or name Like "Feb*" Or name Like "Mar*" Or name Like "Apr*" Or name Like "May*" Or name Like "Jun*" _
    Or name Like "Jul*" Or name Like "Aug*" Or name Like "Sep*" Or name Like "Oct*" Or name Like "Nov*" Or name Like "Dec*" Then

    Me.ComboBox2.AddItem name
    End If
    Next name

    End Sub
    Last edited by LaurieH; 05-20-2013 at 05:06 AM.

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