+ Reply to Thread
Results 1 to 12 of 12

Populating Combo Boxes

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Populating Combo Boxes

    Hello again.....

    Why would this code not work? i had it workign fine last week but had to populate different combo boxes with different ranges so created extra codes to do this, but had to add rngdate1 and ws1 etc as it can not duplicate rngdate and ws, but now none of the combo boxes are being populated with the ranges....


    Private Sub UserForm1_Initialize()
    
    Dim rngDate As Range
    Dim ws As Worksheet
    Set ws = Worksheets("Data2")
    For Each rngDate In ws.Range("WEEKCOMMENCING2")
    Me.ComboBox4.AddItem rngDate.Value
    Next rngDate
    
    Dim rngDate1 As Range
    Dim ws1 As Worksheet
    Set ws1 = Worksheets("Data2")
    For Each rngDate1 In ws1.Range("WEEKCOMMENCING3")
    Me.ComboBox8.AddItem rngDate1.Value
    Next rngDate1
    
    Dim rngDate2 As Range
    Dim ws2 As Worksheet
    Set ws2 = Worksheets("Data2")
    For Each rngDate2 In ws2.Range("ARRIVALAPPLES")
    Me.ComboBox7.AddItem rngDate2.Value
    Next rngDate2
    
    Dim rngDate3 As Range
    Dim ws3 As Worksheet
    Set ws3 = Worksheets("Data2")
    For Each rngDate3 In ws3.Range("NZARRIVALAPPLES")
    Me.ComboBox10.AddItem rngDate3.Value
    Next rngDate3
    
    Dim rngDate4 As Range
    Dim ws4 As Worksheet
    Set ws4 = Worksheets("Data2")
    For Each rngDate4 In ws4.Range("NZARRIVALPEARS")
    Me.ComboBox11.AddItem rngDate4.Value
    Next rngDate4
    
    Dim rngDate5 As Range
    Dim ws5 As Worksheet
    Set ws5 = Worksheets("Data2")
    For Each rngDate5 In ws5.Range("ARRIVALPEARS")
    Me.ComboBox5.AddItem rngDate5.Value
    Next rngDate5
    
    Dim rngDate6 As Range
    Dim ws6 As Worksheet
    Set ws6 = Worksheets("Data2")
    For Each rngDate6 In ws6.Range("SAWKC")
    Me.ComboBox6.AddItem rngDate6.Value
    Next rngDate6
    
    Dim rngDate7 As Range
    Dim ws7 As Worksheet
    Set ws7 = Worksheets("Data2")
    For Each rngDate7 In ws7.Range("NZWKC")
    Me.ComboBox9.AddItem rngDate7.Value
    Next rngDate7
    
    End Sub
    Dan

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Populating Combo Boxes

    see your other post for reason
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Populating Combo Boxes

    Ok i changed Userform1 back to Userform and it works fine... But wasnt before, there is no other code in place yet that shoud cause any errors, the next code to perform is when the user clicks the add control once the user has completed the userform...

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Populating Combo Boxes

    post example of non working file

  5. #5
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Populating Combo Boxes

    Ok, i think ive screwed it right up now....

    It wont let me upload the file im getting this message

    407 [IOErrorEvent type= "ioError" bubbles=false cancelable=false eventPhase=2 text= "Error #2038"]

  6. #6
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Populating Combo Boxes

    I had to disable the enhanced attachments
    Attached Files Attached Files

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Populating Combo Boxes

    I pressed the button multiple times without error. Comboboxes populate and no error is raised.

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Populating Combo Boxes

    did that file fail for you?

    Works as expected for me

  9. #9
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Populating Combo Boxes

    At first yes, then it worked ok, well opened up the userform and populated the combo boxes, havent got to the part of checking its going into the right cells yet, and then it failed and said it was out of range....

    And it works for you? I think im having a bad day!!

  10. #10
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Populating Combo Boxes

    Ok, im now not getting an error message, but there should be a message on pressing the "update rates" button which says "New rates have been added" and it dont

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Populating Combo Boxes

    You only get a msgbox if all combobox values have been selected, due to the Exit sub codes.

  12. #12
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Populating Combo Boxes

    Ah that explains why ok great thanks for your help Andy

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. User Form with with Populating Combo Boxes
    By Maneesh Massey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-23-2013, 04:46 AM
  2. [SOLVED] Populating text boxes from a combo box choice
    By adam.hewitt5 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-27-2012, 01:15 PM
  3. Populating Combo Boxes At Start up
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2009, 11:46 PM
  4. Populating Combo Boxes Still Not Working
    By Tyrell in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-14-2006, 05:00 AM
  5. Populating Combo Boxes
    By Tyrell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2006, 10:45 AM

Tags for this Thread

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