+ Reply to Thread
Results 1 to 10 of 10

Macro to find bold cells and add to combo box

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Macro to find bold cells and add to combo box

    Hi guys, my code would need to look in column B from row 5 for cells that have bold text and each cell value would become an option in the combo box list from the user form.

    here's my code as I tried to adapt but if I don't specify a limit it will crash even if the column is not formatted as bold.
    Please Login or Register  to view this content.
    I tried it with find, findnext but still can't do it.
    Thank you in advance
    Last edited by jeffreybrown; 12-06-2012 at 11:06 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Do you mean a limit to the range you look in?

    That should be limited.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Macro to find bold cells and add to combo box

    Well, I want it to search in the whole column for cells that have bold text. The user may have 1,000 rows or 10,000 rows. is that even possible? if not I'll figure out another way to do it

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro to find bold cells and add to combo box

    If you mean limit the search to the no of rows with data, yes it is possible.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Macro to find bold cells and add to combo box

    Yes, that's what I mean. Because in order to distinguish a category from an item I said that it would be best to be bold. So when a user would want to add an item under a category he should select the one that he prefers from a list with all the available categories.

    But now (with the code you suggested) it shows only one blank option in the combobox, even if I have 2 rows with bold text in column B.
    Last edited by JoTedy; 12-07-2012 at 11:22 AM.

  6. #6
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Macro to find bold cells and add to combo box

    So, it works perfectly if I give it the range manually (eg. B5:B1000) but it stops working if I try to do it dynamically (eg. Range B5 to the last row with data in column B). Do you know why?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Bit of a typo, the & in the code I posted should be a comma.

  8. #8
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Macro to find bold cells and add to combo box

    you mean like this:
    Please Login or Register  to view this content.
    cause it doesn't work that way

  9. #9
    Registered User
    Join Date
    12-06-2012
    Location
    Oxford, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Macro to find bold cells and add to combo box

    I did it, with your help of course
    the code is:
    Please Login or Register  to view this content.
    Thank you for your help Norie

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    I must have been half asleep when I was writing the code - the .Row shouldn't be there.

    Anyway, you got it yourself with an alternative.

+ 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