VBA Highlight Entire Row, Search entire sheet

freerskys

New Member
Joined
Jul 24, 2014
Messages
18
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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Alex Blakenburg

Well-known Member
Joined
Feb 23, 2021
Messages
2,634
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,589
Messages
5,765,317
Members
425,272
Latest member
Umba

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
Top