Excel data cleansing list and transfer delete row to different sheet

Let's say that I've got a sheet - Admin 7 Account - with over 5000 rows (say, columns 'A' - 'N' each).
In another sheet - Account - I have a "to-remove-list" - a single column 'A' with ## values, each containing numerical string (example: 750360).
I have to remove every entire row from Admin 7 Account, if column 'B' contains any value from "to-remove-list" (from column 'A' of sheet "Account").
By removing the entire row, I mean copy row to another sheeet to presevere data and  delete the row and move it up (not leaving the blankspace)
cfhasan1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
As per your description, you may try something like this.....
Sub CleanData()
Dim Sws As Worksheet, RLws As Worksheet, LOGws As Worksheet
Dim Slr As Long, i As Long

Set Sws = Sheets("Admin 7 Account")        'Main Admin Account Sheet
Set RLws = Sheets("To Remove List")         'Sheet which contains "To Remove List"
On Error Resume Next
Set LOGws = Sheets("Delete Log")             'Sheet which will maintain a log for deleted rows
If Err <> 0 Then
    MsgBox "The Delete Log Sheet doesn't exixt in the workbook." & vbNewLine & _
                "Please create one and then try again....", vbExclamation, "Log Sheet Not Found!"
                Exit Sub
End If
Slr = Sws.Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
For i = Slr To 2 Step -1
    If WorksheetFunction.CountIf(RLws.Columns(2), Sws.Cells(i, 1).Value) > 0 Then
        Sws.Cells(i, 1).EntireRow.Copy LOGws.Range("A" & Rows.Count).End(3)(2)
        Sws.Rows(i).Delete
    End If
Next i
Application.ScreenUpdating = True
MsgBox "Task Complete.", vbInformation
End Sub

Open in new window

For details refer to the attached workbook where I have inserted a button on the first sheet which when clicked does what you are trying to achieve and also creates a log on Log Sheet for rows deleted during the code execution.

Hope this helps.
CleanData.xlsm
1
cfhasan1Author Commented:
This is almost exactly what I'm trying to do.  However, I need the Admin Sheet and the Delete log to maintain original format of column headers, etc.  Addition the Remove list is also, based upon the Column headed as Account.

Please advise....
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
On the Log Sheet, you may copy the headers from the Admin Account Sheet, this will be a one time process. Once the Log sheet has all the headers as per the Admin Sheet, you are ready to go.

Or you are talking about something else?
1
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

cfhasan1Author Commented:
I copied and paste source data into spreadsheet with headers. I edited the remove list with items required,and added the headers to the log.  The log is not populating with data.  Please take a look , I must be make a simple mistake somehwere
CleanData-v1.0.xlsm
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You changed the columns of matching numbers now its col. B on both the sheets.
I have tweaked the code and see if this is working for you.
Please see the attached.
CleanData-v1.0.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cfhasan1Author Commented:
You were extremely patient with me and my limited knowledge of VB.  Your solution allowed to clean several data sets in more than half the time.
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Glad to help. :)
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.