Highlights Column when Intersect

sunjam

New Member
Joined
Feb 16, 2013
Messages
49
Hi Guys,

Please help,

when intersect to Column C-AP, highlight cell in column B.

My code here is when intersect to column C only, please edit my codes.

Big Thanks,

Code:
Range("B4:B2000").Interior.ColorIndex = xlNone
    If Not Intersect(Target, Range("C4:C2000")) Is Nothing Then
        Intersect(Target, Range("C4:C2000")).Offset(0, -1).Interior.Pattern = xlPatternLinearGradient
        Intersect(Target, Range("C4:C2000")).Offset(0, -1).Interior.Gradient.Degree = -45
        lngColor0 = Intersect(Target, Range("C4:C2000")).Offset(0, -1).Interior.Gradient.ColorStops(1).Color
        lngColor1 = Intersect(Target, Range("C4:C2000")).Offset(0, -1).Interior.Gradient.ColorStops(2).Color
        Intersect(Target, Range("C4:C2000")).Offset(0, -1).Interior.Gradient.ColorStops.Clear
        Set objColorStop = Intersect(Target, Range("C4:C2000")).Offset(0, -1).Interior.Gradient.ColorStops.Add(0)
        objColorStop.Color = lngColor0
        Set objColorStop = Intersect(Target, Range("C4:C2000")).Offset(0, -1).Interior.Gradient.ColorStops.Add(1)
        objColorStop.Color = RGB(0, 75, 0)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Thanks jbeaucaire

But the target is offset(0,-1)

if I intersect to column D, then Column C will highlight.

the code should highlight cells in bolumn B

this is my code below,


Code:
Range("B4:B2000").Interior.ColorIndex = xlNone
    If Not Intersect(Target, Range("C4:C2000")) Is Nothing Then
        Intersect(Target, Range("C4:C2000")).Offset(0, -1).Interior.Color = RGB(0, 75, 0)
    End If


Big Thanks,
 
Upvote 0
Something like this perhaps:
Code:
Dim cell As Range

    If Not Intersect(Target, Range("C4:AP2000")) Is Nothing Then
        Range("B4:B2000").Interior.ColorIndex = xlNone
        Application.EnableEvents = False
        For Each cell In Intersect(Target, Range("C4:AP2000"))
            With Range("B" & cell.Row)
                .Interior.Pattern = xlPatternLinearGradient
                .Interior.Gradient.Degree = -45
                lngColor0 = .Interior.Gradient.ColorStops(1).Color
                lngColor1 = .Interior.Gradient.ColorStops(2).Color
                .Interior.Gradient.ColorStops.Clear
                Set objColorStop = .Interior.Gradient.ColorStops.Add(0)
                objColorStop.Color = lngColor0
                Set objColorStop = .Interior.Gradient.ColorStops.Add(1)
                objColorStop.Color = RGB(0, 75, 0)
            End With
        Next cell
        Application.EnableEvents = True
    End If
 
Upvote 0

Forum statistics

Threads
1,196,328
Messages
6,014,669
Members
441,834
Latest member
GHOSTOF309

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