+ Reply to Thread
Results 1 to 6 of 6

Coloring rows with 2 colors with varying row count

  1. #1
    Registered User
    Join Date
    04-15-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    36

    Question Coloring rows with 2 colors with varying row count

    Hey All,

    I have a certain problem, that I want to solve, but this is a bit challanging for me. So, the basic thing is that I work with a list of around 2k rows every week, with different IDs for the rows. Each row is for a material that is missing for a certain machine. Since this changes every day, every time i get a new list, the numbers change, depending on Mashine ID and number of material count. So basically, it can happen, that first day I get 5 different machine IDs with 3,12,5,7,8 material numbers, respectively, then Next day I get 2 machines with 23 and 67 materials. So first day 35 rows, next day 90 rows.

    When I'm on a meeting, I would like to see clearly what Machine we are talking about, so I manually color the rows which are under same machine ID. I would like to make a macro for that, so I dont make a mistake when selecting the rows, and of course to cut the time I am working.

    I have thought something of a logic for this, but not sure if this works and of course I don't know the commands needed to use for that or just part, and it als has to be dynamic since number of rows change.

    So basically:

    bscolor as word
    set values to bscolor
    If bscolor is 1 then color is white.
    If bscolor is 2 then color is green.

    macro would start at column A and under the header.
    Paint A2 white then set bscolor 1.

    go to A3 and check if A3=A2

    If yes and bscolor is 1 then paint it bscolor 1 (white).
    If yes and bscolor is 2 then paint it bscolor 2 (green).
    It they are not the same and bscolor is 1, then paint it with bscolor+1 (green) and bscolor=bscolor+1
    It they are not the same and bscolor is 2, then paint it with bscolor-1 (white) and bscolor=bscolor-1

    Repeat this until we have the last data in column.

    After this copy the color formats to entire row respectively.

    Would this work? And what are the commands I have to use for this?

    Thank you very much in advance!

    3nduranc3

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Coloring rows with 2 colors with varying row count

    How about:

    Please Login or Register  to view this content.
    Gary's Student

  3. #3
    Registered User
    Join Date
    04-15-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Coloring rows with 2 colors with varying row count

    This is so cool! It works actually fine, except one little thing, can I make the coloring til a specified column? Lets say not entire row, just from A to W?

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Coloring rows with 2 colors with varying row count

    Here you go:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-15-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Coloring rows with 2 colors with varying row count

    Wow Jakob, you're awsome mate, you helped me a lot, this works just fine!

  6. #6
    Registered User
    Join Date
    04-15-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Coloring rows with 2 colors with varying row count

    Hmm.. I tried this now again, and actually I do see a value problem. I was using this more times, changed some things, but still I have a problem with it. Actually, I would like to color the rows if the values in cells of column I differ. And this seems that he is changing colors depending on column A. It now looks like this, how should I modify it?

    Please Login or Register  to view this content.
    Last edited by 3nduranc3; 04-22-2013 at 02:19 AM.

+ 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