Results 1 to 6 of 6

Thread: Code to condition format the cell colors and font colors of a range values

  1. #1
    Member
    Join Date
    Apr 2014
    Posts
    45
    Rep Power
    0

    Code to condition format the cell colors and font colors of a range values

    how to use VBA code to condition format a range of cells D:D by reference to the color and font color of cell in range B:B,

    thanks in advance,


    condition format cell color.xlsm

  2. #2
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    Here you go:

    Code:
    Sub M_snb()
        sn = [B1:B20]
        sp = [D1:D20]
        
        For j = 1 To UBound(sp)
           Cells(j, 6).Interior.Color = Cells(Application.Match(sp(j, 1), sn, -1) + Abs(IsError(Application.Match(sp(j, 1), sn, 0))), 2).Interior.Color
        Next
    End Sub
    Last edited by snb; 12-11-2015 at 05:01 PM.

  3. #3
    Member
    Join Date
    Apr 2014
    Posts
    45
    Rep Power
    0
    OK, it did work, thanks for the help, appreciate it,

    one more thing, how to change the font color to match B ?

    If i want to apply it to cells (F1:F30, H10:H40), instead of D1:D20, what to change the code, ?
    Last edited by mrprofit; 12-11-2015 at 05:32 PM.

  4. #4
    Member
    Join Date
    Apr 2014
    Posts
    45
    Rep Power
    0
    it doen't seems to condition format the range, is it just copy the colot to Column F?

  5. #5
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    Conditional formatting is meant for those who have no knowledge of VBA.

  6. #6
    Member
    Join Date
    Apr 2014
    Posts
    45
    Rep Power
    0
    i find that there is alternate mthod using VBA to code the excel condition format, how to use the code to apply to my condition format formula?

Similar Threads

  1. Replies: 2
    Last Post: 09-06-2014, 09:38 AM
  2. Replies: 2
    Last Post: 03-04-2014, 09:35 PM
  3. Replies: 3
    Last Post: 11-22-2013, 08:22 AM
  4. data entry to correct cell range...code needs help
    By paul_pearson in forum Excel Help
    Replies: 2
    Last Post: 08-28-2013, 05:26 PM
  5. Replies: 4
    Last Post: 02-22-2013, 02:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •