+ Reply to Thread
Results 1 to 7 of 7

Need help: Macro that colors rows based on specific text

  1. #1
    Registered User
    Join Date
    07-21-2014
    Location
    AMS
    MS-Off Ver
    2010
    Posts
    3

    Need help: Macro that colors rows based on specific text

    Dear all,

    I am googling this one in the past day - still did not find one solution that suits my needs.

    Basically I am working on automation of some charts. I have a list of 20-30 countries that should always be represented in the chart with a specific color. Every month the position of these countries will move, but also the selection (each chart will have more or less 5 countries).

    Very simple, what I would like is if you find Germany in the data set below color the full row in blue. Of course we need to have each country covered and the macro not to stop after finding one market.

    Germany 12 14 15 16 14 16
    Brazil 12 14 15 16 14 16
    Romania 12 14 15 16 14 16
    Poland 12 14 15 16 14 16
    France 12 14 15 16 14 16

    Very happy if you can help me with this.
    Thank you in advance!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: Need help: Macro that colors rows based on specific text

    If it is just coloring rows (as title states) and you have excel 2010 there is no need for macro.
    Just conditional formatting with rule for each country based on formula will be enough.
    See attachment (and check what are conditional formatting rukes there)
    Wherever in column A in bordered rcells you write Germany - the corresponding row will become blue.
    Write Poland in column A - it will become white-red gradient.
    Attached Files Attached Files
    Best Regards,

    Kaper

  3. #3
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Need help: Macro that colors rows based on specific text

    You can play around with the colors and change the names that can be found but here is an idea of how to do it. For this you need to select the entire range of names that you want to apply this to and then run the macro creatively named Macro1

    edit: Kapers idea is easier to customize color wise and easier to implement for new countries. I would suggest using his proposal.
    Attached Files Attached Files
    Last edited by Hawkeye16; 07-21-2014 at 05:40 AM.
    Despite the high cost of living, it remains very popular.

    Don't forget to mark threads SOLVED when you get an answer and rep all the geniouses that helped you today!

  4. #4
    Registered User
    Join Date
    07-21-2014
    Location
    AMS
    MS-Off Ver
    2010
    Posts
    3

    Re: Need help: Macro that colors rows based on specific text

    Dear both,

    thank you for your fast answer

    still, I have tried before the conditional formatting and once I start having more than 3 markets and a longer area where to make the changes the full conditional formatting goes bananas..

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,632

    Re: Need help: Macro that colors rows based on specific text

    have you analyzed my sample?
    OK. I did extra version of with already 5 formats (only 4 visible but try to add Nederlands data you will see the fifth format is there
    As a reference, also attached a screenshot, but from Polish version of Excel - location of controls, options, etc. is the same)
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-21-2014
    Location
    AMS
    MS-Off Ver
    2010
    Posts
    3

    Re: Need help: Macro that colors rows based on specific text

    Hello Kaper,

    I did look at your sample from the beginning. I am trying this solution since last week but I do not understand why it does not work for me. I tried also using Search as a function but still the way colors are changing is weird and not incorrect.

    For example if there is any empty row between the data, it sometimes colors that row as well, sometimes no (very randomly).
    All conditions for some countries work, for some no..

    Again, I am using the exact things as I am checking conditional formatting since last week..

    Is there any other solution? That's why I was trying to find a macro to help me with this...

    Thank you again for your help in advance!

  7. #7
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Need help: Macro that colors rows based on specific text

    If you really want a macro solution you could check out the workbook I attached along with explanation.

    If you are getting variable results with the conditional formatting you can make sure that you only have the rules you want, and that all cells have the same rules. I would bet that you have different rules or multiple rules overlapping on the cells you are getting weird results on, although that is hard to debug without a copy of the workbook.

+ 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. Macro/VBA to Add Rows based on presence/absence of specific text content
    By cmaunder in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2013, 01:15 PM
  2. [SOLVED] Macro/VBA to Change Order of Rows/Add Rows based on specific text content presence/absence
    By cmaunder in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2013, 04:50 PM
  3. [SOLVED] Perform calculations for multiple rows based on specific column text
    By justinmirsky in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 03-31-2013, 08:20 PM
  4. How do I create a Macro to move rows based on a specific value.
    By Total Excel Noob in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-30-2012, 03:11 PM
  5. Conditional format different rows based on specific text
    By theshark43 in forum Excel General
    Replies: 1
    Last Post: 08-15-2011, 04:54 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