+ Reply to Thread
Results 1 to 20 of 20

For Each Loop with Activex ComboBox

  1. #1
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    For Each Loop with Activex ComboBox

    I cross-posted this on https://www.mrexcel.com/forum/excel-...lastvalue.html



    Hi, I have 6 ActiveX Comboboxes and I want to loop through all values of all comboboxes.

    I would like help with how to:

    1. Select a Combobox and change it's values from firstItem to lastItem (I want to see the value in the Combobox change)

    2. Use a select case which only runs specific values of ComboBox.

    Ex. Combobox1 value is Sweden and I only want to run combobox1 and combobox2 when the values is Sweden.
    Last edited by waimea; 08-17-2018 at 11:30 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: For Each Loop with Activex ComboBox

    Rule 08: Cross-posting Without Telling Us

    Your post does not comply with Rule 8 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question. If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    If you have less than 10 posts, do not try to copy and paste the link. Instead, type the link out in your thread.

    No further help to be offered, please, until the OP has complied with this request.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: For Each Loop with Activex ComboBox

    Can anyone show me how to increment an activex combobox by 1?

  4. #4
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: For Each Loop with Activex ComboBox

    can you post an example file and provide some more info about what you want?

    maybe this gets you started:

    Please Login or Register  to view this content.
    Last edited by SjonR; 08-18-2018 at 05:05 AM.

  5. #5
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: For Each Loop with Activex ComboBox

    Thank you for your reply.

    Yes, I can post a sample workbook.

    Your code works but I want to access the items in the combobox, not set the items in the combobox.
    Attached Files Attached Files
    Last edited by waimea; 08-18-2018 at 05:20 AM.

  6. #6
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: For Each Loop with Activex ComboBox

    Would it be possible to use select case with this code?

    It seems that I can use

    Sheets("Test").ComboBox1.ListIndex = 0 ' first item in combobox1

    to change the value of the comboboxes.

    I am still trying to use select case to have a case for ComboBox1 listIndex = 0 etc.
    Last edited by waimea; 08-18-2018 at 05:35 AM.

  7. #7
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: For Each Loop with Activex ComboBox

    Sub Try()

    Dim k As Integer
    Dim l As Integer
    Dim m As Integer
    Dim n As Integer
    Dim o As Integer

    For k = 0 To 21
    Sheets("Test").L鄚1.ListIndex = k

    For l = 0 To 25
    Sheets("Test").Kommun1.ListIndex = l

    For m = 0 To 21
    Sheets("Test").L鄚2.ListIndex = m

    For n = 0 To 25
    Sheets("Test").Kommun2.ListIndex = n

    End sub

    This code works ok. I need help with:

    1. Finding the length of a ComboBox list.

    2. Stating a select case statement

    I am thinking that I can do simple case with two for statements.

    For k = 0 To 1
    Sheets("Test").L鄚1.ListIndex = k

    For l = 0 To 25
    Sheets("Test").Kommun1.ListIndex = l


    Any help is much appreciated!!!

  8. #8
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: For Each Loop with Activex ComboBox

    Please Login or Register  to view this content.
    This code works ok. I need help with:

    1. Finding the length of a ComboBox list.

    2. Stating a select case statement

    I am thinking that I can do simple case with two for statements.

    Please Login or Register  to view this content.

    Any help is much appreciated!!!

  9. #9
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: For Each Loop with Activex ComboBox

    Why do you use comboboxes to store data? Isn't a table what you need.

  10. #10
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: For Each Loop with Activex ComboBox

    Hi, thank you for your reply. I am using ComboBox to store data because it lets the user select one option and then I calculate VLOOKUP for that option.

    Now I am trying to iterate through all possible combinations of the user option.

    How would I use a table in this context?

  11. #11
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: For Each Loop with Activex ComboBox

    Length of combobox list:

    Please Login or Register  to view this content.
    I haven't got a clue about the select case you are demanding.

  12. #12
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: For Each Loop with Activex ComboBox

    Thank you for your reply.

    I am not demanding, I am kindly asking.

    How would I convert a for loop to a for each loop?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: For Each Loop with Activex ComboBox

    is this what you are looking for? And take no offense to my wrong choice of words. English is not my native language


    Please Login or Register  to view this content.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: For Each Loop with Activex ComboBox

    Yes, this is exactly what I want!

    Thank you very much!

    With the cases I mean that one case would be Sweden, Stockholm and Sweden, Stockholm.

    Another case would be Norway, Oslo and Norway, Olso.

  15. #15
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: For Each Loop with Activex ComboBox

    That's great!

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: For Each Loop with Activex ComboBox

    Rule 08: Cross-posting Without Telling Us

    Your post does not comply with Rule 8 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question. If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    If you have less than 10 posts, do not try to copy and paste the link. Instead, type the link out in your thread.

    No further help to be offered, please, until the OP has complied with this request.

  17. #17
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: For Each Loop with Activex ComboBox

    waimea, please take the time to review our rules. There aren't many, and they are all important.

    Although you added a cross-post link in your first post, you cross-posted to a third forum as well. Please add a link to your Mr. Excel post.

    In addition you need CODE tags in post #7.

    Your post does not comply with Rule 3 of our Forum Rules: Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  18. #18
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Re: For Each Loop with Activex ComboBox

    I will review the rules and I will stop crossposting at several forums!

    I am unable to edit post#7.

  19. #19
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: For Each Loop with Activex ComboBox

    Quote Originally Posted by waimea View Post
    I will review the rules and I will stop crossposting at several forums!

    I am unable to edit post#7.
    Cross-posting is fine! We just ask that you provide a link so there is not duplication of effort.

    I can't edit post 7 either, I think it's a database problem.

  20. #20
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: For Each Loop with Activex ComboBox

    removed by me!
    Last edited by SjonR; 08-19-2018 at 05:56 AM.

+ 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. ActiveX ComboBox
    By mp3909 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2018, 04:05 PM
  2. [SOLVED] ActiveX COmboBox
    By ftsc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2016, 10:29 PM
  3. Replies: 0
    Last Post: 10-26-2015, 04:25 PM
  4. ActiveX combobox datalist dependant on previous combobox selections
    By Mrs Poodle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2014, 07:07 AM
  5. [SOLVED] fill listbox (ActiveX) based combobox (ActiveX)
    By elsg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-31-2014, 11:25 AM
  6. Populate a activeX combobox from a selection of another combobox
    By ptramel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-28-2009, 06:50 PM
  7. ActiveX ComboBox: Almost there!!!
    By akexcel in forum Excel General
    Replies: 2
    Last Post: 10-23-2006, 01:09 PM

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