Add row below if value is found on another sheet

tropics123

Board Regular
Joined
May 11, 2016
Messages
85
Hi, Thank you in advance for your help. Is there a macro to add a row below if the value on the current sheet is found on another sheet?

Example:

Sheet 1 has these names in column B:
James
Bob
Mary

If those names appear on Sheet 2, then add a row below each of those names on Sheet1.
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Assuming your names start in sheet1, cell B2 (change to suit your layout):
Code:
Sub tropics123()
Dim c As Range, fnd As Variant, fAdr As String
Application.ScreenUpdating = False
For Each c In Sheets("Sheet1").Range("B2:B" & Sheets("Sheet1").Cells(Rows.Count, "B").End(xlUp).Row)
    If c.Value <> "" Then
        Set fnd = Sheets("Sheet2").Cells.Find(what:=c.Value, lookat:=xlPart, LookIn:=xlValues, MatchCase:=True)
        If Not fnd Is Nothing Then
            Sheets("Sheet1").Cells(c.Row + 1, "B").EntireRow.Insert
        End If
    End If
Next c
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,001
Messages
6,122,648
Members
449,092
Latest member
peppernaut

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