Tricky little Colour macro needed

mikemcbain

Board Regular
Joined
Nov 14, 2005
Messages
152
Office Version
  1. 365
Platform
  1. Windows
G'day Magicians

Can someone please help me with this one?

I have a macro that colours cells AF2:AF6 with lime green (65250) and also colours some of the cells in U2:U6

I want to add to that macro or create another macro that will look at those two columns and if there is a cell coloured in both columns on the same row will then colour those cells/row in column J ?

With thanks in anticipation

Mike.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Steve

Cells AF2:AF6 are permanently coloured and the piece of code selecting which cells in Col U will be similarly coloured is...

64: Next rw_v

For rw_w = 2 To rw_s
If Cells(rw_w, 21) = 0 Then
Cells(rw_w, 21).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65250
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next rw_w

...so that is selecting any cell containing a zero to be coloured.

And I am hoping to be able to auto colour any of those five cells in Col J where Cols U & AF are both coloured.

Cheers

Mike.
 
Upvote 0
How about
Code:
For rw_w = 2 To rw_s
   If Range("U" & rw_w).Value = 0 Then
      With Range("J" & rw_w & ",U" & rw_w).Interior
         .Pattern = xlSolid
         .PatternColorIndex = xlAutomatic
         .Color = 65250
         .TintAndShade = 0
         .PatternTintAndShade = 0
      End With
   End If
Next rw_w
 
Upvote 0
Many thanks Fluff however that colours all the cells showing a zero in Col U instead of only those that are in rows 2 to 6 and so coloured in Col AF?

With thanks

Mike.
 
Last edited:
Upvote 0
Ok, how about
Code:
For rw_w = 2 To rw_s
   If Range("U" & rw_w).Value = 0 And rw_s < 7 Then
      With Range("J" & rw_w & ",U" & rw_w).Interior
         .Pattern = xlSolid
         .PatternColorIndex = xlAutomatic
         .Color = 65250
         .TintAndShade = 0
         .PatternTintAndShade = 0
      End With
   Else
      With Range("U" & rw_w).Interior
         .Pattern = xlSolid
         .PatternColorIndex = xlAutomatic
         .Color = 65250
         .TintAndShade = 0
         .PatternTintAndShade = 0
      End With
   End If
Next rw_w
 
Upvote 0
Thank you Fluff but no sorry that one is colouring the whole of column U and none of the Cells in Col J instead of just those sells in the rows that are coloured in both Cols U and AF?

Mike.
 
Last edited:
Upvote 0
how about
Code:
For rw_w = 2 To rw_s
   If Range("U" & rw_w).Value = 0 Then
      If rw_w < 7 Then
         With Range("J" & rw_w & ",U" & rw_w).Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 65250
            .TintAndShade = 0
            .PatternTintAndShade = 0
         End With
      Else
         With Range("U" & rw_w).Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 65250
            .TintAndShade = 0
            .PatternTintAndShade = 0
         End With
      End If
   End If
Next rw_w
 
Upvote 0
G'day again Fluff

Truly MAGICAL!

In lieu of the gift you deserve can I ask that you please take a moment to smell the roses from your garden (or Avatar)?

I remain indebted to you....

Mike.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,563
Members
448,972
Latest member
Shantanu2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top