+ Reply to Thread
Results 1 to 5 of 5

Manually Update Listindex

  1. #1
    DB
    Guest

    Manually Update Listindex

    I have a combobox on a user form that is populated when the form opens. The
    listindex is not updated unless I "reselect" the same value from the dropdown
    menu. How can I have the listindex automatically update when the combobox is
    populated. This is on a pretty new version of Excel for Mac. I don't have
    this problem with the older version of Excel for Mac.

    Thanks for any help

    DB

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello DB,

    What OS are you running? I tested setting the Listindex of ComboBox using Excel with OS X . I placed the code in the User Form Initialize Event module with no problems. I used ComboBox1.ListIndex = 3 to bring up the 4th item in my list of 5 with no problems. Maybe you should post your code.

    Sincerely,
    Leith Ross

  3. #3
    Robin Hammond
    Guest

    Re: Manually Update Listindex

    Can't you just set the listindex at the end of your population code.

    Something like

    Private Sub UserForm_Initialize()
    Dim lCounter As Long
    With cbInput
    Application.EnableEvents = False
    For lCounter = 1 To 10
    .AddItem lCounter
    Next lCounter
    Application.EnableEvents = True
    .ListIndex = 0
    End With
    End Sub

    Robin Hammond
    www.enhanceddatasystems.com

    "DB" <[email protected]> wrote in message
    news:[email protected]...
    >I have a combobox on a user form that is populated when the form opens.
    >The
    > listindex is not updated unless I "reselect" the same value from the
    > dropdown
    > menu. How can I have the listindex automatically update when the combobox
    > is
    > populated. This is on a pretty new version of Excel for Mac. I don't
    > have
    > this problem with the older version of Excel for Mac.
    >
    > Thanks for any help
    >
    > DB




  4. #4
    DB
    Guest

    Re: Manually Update Listindex



    "Leith Ross" wrote:

    >
    > Hello DB,
    >
    > What OS are you running? I tested setting the Listindex of ComboBox
    > using Excel with OS X . I placed the code in the User Form Initialize
    > Event module with no problems. I used ComboBox1.ListIndex = 3 to bring
    > up the 4th item in my list of 5 with no problems. Maybe you should post
    > your code.
    >
    > Sincerely,
    > Leith Ross
    >
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=378251
    >
    >


  5. #5
    DB
    Guest

    Re: Manually Update Listindex

    Basically, the combobox2 list depends on the value of combobox1. If I select
    a value from the combobox1 list, combobox2 works just fine. However, if the
    value of combobox1 is set by code (see below) to a value that is the same as
    one in the list for combobox1, the list index does not change accordingly. I
    just had a thought: do you think I need to change the order of the two lines
    of code in the Initialize sub?

    Private Sub UserForm_Initialize()
    ComboBox1.Value = Sheets("Sheet1").Cells(4, 3).Value
    ComboBox1.List = Sheets("Sheet2").Range("B5:B10").Value
    End Sub
    Private Sub ComboBox2_Enter()
    Dim ListRow As Long
    ListRow = ComboBox1.ListIndex + 5
    ComboBox2.AddItem (Sheets("Sheet2").Cells(ListRow, 3).Value)
    End Sub

    "Leith Ross" wrote:

    >
    > Hello DB,
    >
    > What OS are you running? I tested setting the Listindex of ComboBox
    > using Excel with OS X . I placed the code in the User Form Initialize
    > Event module with no problems. I used ComboBox1.ListIndex = 3 to bring
    > up the 4th item in my list of 5 with no problems. Maybe you should post
    > your code.
    >
    > Sincerely,
    > Leith Ross
    >
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=378251
    >
    >


+ 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