Highlight Cell Range

micha3l87

New Member
Joined
Apr 15, 2017
Messages
13
Hey Everyone,

I was hoping someone would be able to help me with what I think will be pretty simple.

When the user clicks a cell in column A, take that cells value subtract 10 and highlight that range in the column.

For example if I click in cell A21 (3113)-(10) = 3103
So highlight A21 to A17

I was going to upload my workbook, but I can't seem to find a attachment button
thank you for any help!
 
Yeah you’re right it should have been A19 in that example

Try this

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim r As Range, i As Long
    Set r = Range("A16", Range("A" & Rows.Count).End(xlUp))
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, r) Is Nothing Then
        r.Interior.ColorIndex = xlNone
        For i = Cells(Target.Row, "A") To r.Cells(1).Row Step -1
            If Cells(i, "A") <= Target And Cells(i, "A") >= Target.Value - 10 Then
                Cells(i, "A").Interior.ColorIndex = 6
            End If
        Next
    End If
End Sub
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,215,467
Messages
6,124,984
Members
449,201
Latest member
Lunzwe73

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