+ Reply to Thread
Results 1 to 11 of 11

Using If to apply color

  1. #1
    Registered User
    Join Date
    03-10-2019
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    31

    Using If to apply color

    Hello I am trying to use If to apply color to a range base on the text inside.
    so the first part of the code I wrote I got
    Please Login or Register  to view this content.
    now I am trying to run a loop but I can't make it work.
    Please Login or Register  to view this content.
    can someone please help me figure this out .
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Using If to apply color

    You are using i to loop, but you are not using it in the internal logic.

    As well, you've already set myrg as range object. You don't need to nest myrg within Range().

    i = 1 is redundant as you are specifying range of i's to iterate over (1 to 10).

    So something like below would work.
    Please Login or Register  to view this content.
    Last edited by CK76; 09-16-2019 at 10:35 AM. Reason: Edit: Typo "next" to "nest"
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Using If to apply color

    Give this a go

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Using If to apply color

    Here is another way to do it without using a loop...
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-15-2015
    Location
    beirut
    MS-Off Ver
    2010
    Posts
    107

    Re: Using If to apply color

    Try this macro
    Please Login or Register  to view this content.
    Last edited by salim ali; 09-16-2019 at 10:44 AM.

  6. #6
    Registered User
    Join Date
    03-10-2019
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    31

    Re: Using If to apply color

    Thanks a lot for the replies, they all work great, I just have one more question, is it possible to use the same color from the cell that was colored to the rows that goes from columns A to column F and going down?
    if so , what needs to be tweaked in order to do it ?
    So put it like this, I already got the cell colored on column A can I apply the same color the rest of the cells from column A to F?
    Thanks again for the replies.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Using If to apply color

    In my example...

    Please Login or Register  to view this content.

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Using If to apply color

    Just add resize to the cell range to color.
    A-F = column size of 6. So...
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-10-2019
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    31

    Re: Using If to apply color

    Yes, thanks a lot this is what I was looking for .

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Using If to apply color

    You are very welcome and thanks for the feedback. We are all happy to help.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  11. #11
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Using If to apply color

    You are welcome and thanks for the rep.

    If your question is answered, please mark the thread as solved, using thread tool found at top of your initial post.

+ 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. [SOLVED] Mimic Font Color Picker - Apply Active(?) Color
    By delaing in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-26-2017, 02:41 PM
  2. Apply Color to chart based on Data source text color
    By ajm1991 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2016, 08:41 PM
  3. Any way to apply a color theme by changing the color of one cell ?
    By KomicJ in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-02-2016, 01:11 PM
  4. apply color fill through formula ????
    By nicomedis in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-01-2015, 11:30 AM
  5. Excel 2007 : Color Themes don't apply
    By thunter5 in forum Excel General
    Replies: 2
    Last Post: 09-25-2010, 01:23 AM
  6. apply color to a cell using a formula
    By planchao in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-13-2008, 03:24 PM
  7. [SOLVED] How do I apply color in cells ..color now shown only in print prev
    By bonadimi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-25-2006, 02:40 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