Formatting Adjacent cell to what is being Matched

hazmat

New Member
Joined
Jun 14, 2019
Messages
19
Been trying all day to figure this out, with no luck. I got the Format part working but now I'm lost.

What would I do in this code, so that the cell in the adjacent column (E8:E37) next to the Match, changes color, instead of the cell that I'm using for the Match (D8:D37).
So in other words, If D8 matches AA8, I want E8 to change color and not D8.

Thanks

VBA Code:
Sub FillColor()
    
    Dim Dcell As Range
    For Each Dcell In ActiveSheet.Range("D8:D37")
        If Not IsError(Application.Match(Dcell, Range("AA8:AA37"), 0)) Then
            Dcell.Interior.colorIndex = 4 
        Else
            Dcell.Interior.colorIndex = none 
        End If
    Next Dcell
    
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You need to use Offset like
VBA Code:
Dcell.Offset(, 1).Interior.colorIndex
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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