VBA Highlight Entire Row, Search entire sheet

freerskys

New Member
Joined
Jul 24, 2014
Messages
29
Office Version
  1. 2010
Platform
  1. Windows
I am trying to highlight an entire row. If a cell in Sheet 2 column A,
Matches a cell in Sheet 1 column A, highlight Sheet 2 entire row, matched in column A.

I appreciate any help.
This works for something else that I need, I would like to add the highlight part with this code.



Sub WardCopyPaste()
Dim Fnd As Range, Cl As Range
With Sheets("sheet1")

For Each Cl In .Range("A1", .Range("A" & Rows.Count).End(xlUp))
Set Fnd = Sheets("Sheet2").Columns("A:A").Find(Cl.Value, , xlFormulas, xlWhole, xlByRows, xlNext, False, , False)
If Not Fnd Is Nothing Then If Cl.Offset(, 6).Value = 0 Then Cl.Offset(, 6).Value = Fnd.Offset(, 6).Value
Next Cl
End With
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Will this do what you want:-
VBA Code:
Sub WardCopyPaste()
    Dim Fnd As Range, Cl As Range
    With Sheets("sheet1")
        For Each Cl In .Range("A1", .Range("A" & Rows.Count).End(xlUp))
            Set Fnd = Sheets("Sheet2").Columns("A:A").Find(Cl.Value, , xlFormulas, xlWhole, xlByRows, xlNext, False, , False)
            If Not Fnd Is Nothing Then
                With Fnd.EntireRow.Interior
                    .Color = vbYellow
                End With
            
                If Cl.Offset(, 6).Value = 0 Then Cl.Offset(, 6).Value = Fnd.Offset(, 6).Value
            End If
        Next Cl
    End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,583
Messages
6,120,380
Members
448,955
Latest member
BatCoder

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