+ Reply to Thread
Results 1 to 3 of 3

Change color of text depending on condition using vba

  1. #1
    Forum Contributor
    Join Date
    10-16-2010
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2003, 2010
    Posts
    151

    Change color of text depending on condition using vba

    Greetings all

    I have a macro that generates a weekly report that I am having a bit of difficulty with. There is a table detailing production as the main part of the report, I have it formatted with vba to alternate colors of rows and that all works fine I got this using the recorder:

    Please Login or Register  to view this content.
    The column I need to conditionally format is M and when I tried it it just cleared out all the alternating bands in that column where the conditions were met.

    The problem I am having is highlighting lower than expected results and higher than expected results. I have a difficult time with conditional formatting without vba, but I am lost trying to get it coded using vba, but the report is rebuilt basically from the ground up every week so this needs to be part of the automated generation.

    Any help would be greatly appreciated.
    Last edited by jacob@thepenpoint; 07-31-2012 at 09:09 AM.
    Jacob Albers
    Excel 2003 & 2010

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Change color of text depending on condition using vba

    It would have been helpful if you had given a small extract of your data sheet. In the absence of that I designed a small data sheet
    from A1 t0 D10

    56 64 37 5
    67 25 90 31
    44 17 45 2
    76 86 70 43
    65 83 8 100
    52 28 58 65
    77 67 17 36
    57 74 59 70
    52 67 85 80
    90 15 93 77

    copy this data and experiment with the macro given below
    I have given a new macro without "format conditions" etc. you modify the macro to suit your data
    the first loop changes the colors of alternate rows
    the second loop gives conditional for a specific column for a specific condition.



    Please Login or Register  to view this content.

    will this be of any help
    I am not an expert. better solutions may be available
    [email protected]

  3. #3
    Forum Contributor
    Join Date
    10-16-2010
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2003, 2010
    Posts
    151

    Re: Change color of text depending on condition using vba

    Thanks Venkat! Looks like this will work perfectly, sorry for not uploading data with the post. I think I know a little bit about working with VBA then I see something as simple and clean as this solution and realize that I haven't even scratched the surface.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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