Find and highlight its matching row using vba

agasi

New Member
Joined
Nov 22, 2016
Messages
48
How can this be done using vba?

If range(" G1").value="To be deleted", go and find its FIRST matching row in the table based on same values in columns a,b,c,d.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
How can this be done using vba?

If range(" G1").value="To be deleted", go and find its FIRST matching row in the table based on same values in columns a,b,c,d.

agasi,

This code finds the row and SELECTS that row in columns A, B, C, & D:
You can change SELECT to DELETE.
Perpa

Code:
Sub MatchingRow()
Dim c As Range
Dim lr as Integer

lr = Range("D" & Rows.Count).End(xlUp).Row
   With Sheets("Sheet1").Range("A2:D" & lr)
       Set c = .Find(What:=Cells(1, "G"), LookIn:=xlValues, LookAt:=xlWhole)
       rw = c.Row - 1
       If Not c Is Nothing Then .Range("A" & rw & ":D" & rw).[COLOR=#ff0000]Select[/COLOR]
   End With
End Sub

Excel 2007
A
B
C
D
E
F
G
1
25
2
3
4
12
5
15
6
17
7
25
8
15
9
12
10

<tbody>
</tbody>
Sheet1
 
Upvote 0
Perpa
thanks. I have just seen your reply. Hmm, I am not sure it is the one I was looking for. Anyway, I am using another approach using same colours, which I have just posted another question.
 
Upvote 0

Forum statistics

Threads
1,203,097
Messages
6,053,519
Members
444,669
Latest member
Renarian

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