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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,814
Messages
6,121,711
Members
449,049
Latest member
THMarana

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