If names found on column, move row to another sheet

Yulyo

Board Regular
Joined
Jul 17, 2017
Messages
94
Hi all,
Could you please help me with a small macro, that should do as follows?
- i have an excel file with 3 sheets: "Central", "Intern", "Extern"
- on sheet 'Central", column A, i have some names (Steve, John, Michael, etc)
- i need a macro that can look on sheet "Central", Column A, and if any of these names are present in column A, move the rows to sheet "Intern".

Thank you in advance!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Cross posted https://www.excelforum.com/excel-pr...ound-on-column-move-row-to-another-sheet.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
What about the following

Code:
Sub MoveLines()'https://www.mrexcel.com/forum/excel-questions/1077420-if-names-found-column-move-row-another-sheet.html


'declarations
Dim LastRowCentral As Long, LastRowIntern As Long, i As Integer, FindName As String


Application.ScreenUpdating = False


'Find LastRows
LastRowCentral = Sheets("Central").Cells(Rows.Count, "A").End(xlUp).Row
LastRowIntern = Sheets("Intern").Cells(Rows.Count, "A").End(xlUp).Row


FindName = InputBox("Enter the name to find", "Search")
'FindName = Sheets("Central").Range("D1").Value 'This line could be used if you had a dropdown in cell D1 for example


For i = LastRowCentral To 2 Step -1
    If Cells(i, 1).Value = FindName Then
    Cells(i, 1).EntireRow.Cut Sheets("Intern").Cells(LastRowIntern + 1, 1)
    Cells(i, 1).EntireRow.Delete
    LastRowIntern = LastRowIntern + 1
    End If
Next i


Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,354
Members
449,155
Latest member
ravioli44

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