How to darken or lighten an existing fill colour?

stefanaalten

Board Regular
Joined
Feb 1, 2011
Messages
71
Office Version
  1. 365
Platform
  1. Windows
I'd like to apply some fill colours to a grid which represents events (in rows) and dates (in columns) to make it easier to distinguish entries.

I have manually applied fill colours to the columns. For the sake of argument, alternating columns are in one of three shades of grey. I would also like to show alternating rows in different shades/colours but without "overwriting" the colour fill applied in the columns. i.e. the rows should take whatever colour is there already (column colour formatting) and either make it a bit lighter or a bit darker. Doing this manually would be a real chore!

Where there are entries in the grid, a conditional formatting rule applies a strong primary colour based on the cell contents and this should "overwrite" whatever colour the cell is, irrespective of row or column.

I don't know how to insert an image here but hopefully I've explained what I'm trying to accomplish.

Can anyone help?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Here's some code, give this a try:

Code:
Sub Coloring()
    Dim ni As Integer, nj As Integer, i As Integer, j As Integer
    UsedRange.Select
    ni = Selection.Rows.Count
    nj = Selection.Columns.Count
    For i = 1 To ni
        For j = 1 To nj
            If (i / 3 - WorksheetFunction.Floor(i / 3, 1)) * 3 = 0 Then Cells(i, j).Interior.Color = 60000
            If (i / 3 - WorksheetFunction.Floor(i / 3, 1)) * 3 = 1 Then Cells(i, j).Interior.Color = 40000
            If (i / 3 - WorksheetFunction.Floor(i / 3, 1)) * 3 = 2 Then Cells(i, j).Interior.Color = 50000
            If (j / 3 - WorksheetFunction.Floor(j / 3, 1)) * 3 = 1 Then Cells(i, j).Interior.TintAndShade = 0.1
            If (j / 3 - WorksheetFunction.Floor(j / 3, 1)) * 3 = 2 Then Cells(i, j).Interior.TintAndShade = 0.2
            If (j / 3 - WorksheetFunction.Floor(j / 3, 1)) * 3 = 0 Then Cells(i, j).Interior.TintAndShade = 0.3
        Next j
    Next i
End Sub

You should be able to change the colors to gray or whatever, just change the interior.color = # to the appropriate numbers.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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