+ Reply to Thread
Results 1 to 5 of 5

Need help writing Macro for shading rows multiple colors

  1. #1
    Registered User
    Join Date
    12-24-2014
    Location
    East Texas
    MS-Off Ver
    2010 & 2013
    Posts
    17

    Need help writing Macro for shading rows multiple colors

    I am trying to help a friend with his sheets. I have several different strings of numbers that range from 2 numbers like 68 to 7 numbers like 4444864 that I need to shade a different color on several sheets in several books, Can anyone start a Macro for me and explain how I can shade these. I believe if someone gets me started I can take off with it once I understand the concept.

    How my sheets work is I add new numbers into 4 columns (columns STUV for example) once new numbers are added to STUV the numbers in column "R" for example will change therefore a new string needs to get shaded a different color.


    How do I write a Macro for say the 642 in column "R" which is bright yellow shade with Bold Royal Blue font and a royal bold border. The reason the number 2 changed to yellow font and blue shade is because it is part of another string that is opposite 246 which is royal blue shade and bright yellow font with a bright yellow border. For all intentional purposes I can just color code the 64 in one and the 24 in the other. The other shade for example would be the 6-10-2 which is black shade with bold red font and a red border. you can glance across this picture or spreadsheet and see the different shades I use. I want to be able to write a Macro for all of them. Keep in mind I have approx 18 different columns i will want to shade so I will need to know how to include several columns to do the same rules (example B, R, AH, AX.....)

    VBA for shading.jpg

    Shading No Formulas.xlsxVBA for shading.jpg



    Thanks for your help

  2. #2
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: Need help writing Macro for shading rows multiple colors

    Without going through all your options, here's the pattern for changing cell properties
    Please Login or Register  to view this content.
    You could use variables for the colours, range, etc. and use it as a vba function
    If this helped, please click (*) Add Reputation

  3. #3
    Registered User
    Join Date
    12-24-2014
    Location
    East Texas
    MS-Off Ver
    2010 & 2013
    Posts
    17

    Re: Need help writing Macro for shading rows multiple colors

    Thank you hectop, I think this is exactly what I was looking for. Is there a certain place to go that will list all the different colors available or is that withing our spreadsheet options. Keep in mind I am a newbie when it comes to writing Macros and VBA so I need it in 101 terms LOL

  4. #4
    Registered User
    Join Date
    12-24-2014
    Location
    East Texas
    MS-Off Ver
    2010 & 2013
    Posts
    17

    Re: Need help writing Macro for shading rows multiple colors

    I am just beginning and I am getting an error, can you tel me what I am missing?

    End Sub.jpg

  5. #5
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: Need help writing Macro for shading rows multiple colors

    You need an End With before the End Sub.

    The other thing to consider is since you're using vba, you can go through the sheet cell by cell and you don't necessarily have to use the ranges the same way.

    This site has some information on colours:http://dmcritchie.mvps.org/excel/colors.htm

+ 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] Shading multiple rows with conditional formatting
    By BigTonyP in forum Excel General
    Replies: 3
    Last Post: 08-24-2012, 11:17 AM
  2. Shading Cell Colors in Excel 2003
    By scotfitz in forum Excel General
    Replies: 2
    Last Post: 06-02-2008, 08:30 AM
  3. Simple Cell Shading with different than default colors?
    By joeyeti in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-18-2007, 05:02 AM
  4. Background Cell shading colors
    By Dean in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2006, 10:20 AM
  5. [SOLVED] How to add fill colors (cell shading) in EXCEL?
    By Donna Sherman in forum Excel General
    Replies: 2
    Last Post: 04-21-2005, 03:06 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