I have a some data on sheet 1 column A and also some data on sheet 2.
Now I need a VBA code if have the same data on sheet 2 delete the row on sheet 2 of that data .
Note : just check with sheet 1 column A .
Thank you very much for your big help .
I have a some data on sheet 1 column A and also some data on sheet 2.
Now I need a VBA code if have the same data on sheet 2 delete the row on sheet 2 of that data .
Note : just check with sheet 1 column A .
Thank you very much for your big help .
so you're comparing column A's of Sheet1 & Sheet2, and deleting the matching rows from Sheet2...
if this is the scenario then try :
[VBA]
Sub DelMatchedRows()
Dim LastRow As Long, i As Long, mRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For i = 1 To LastRow
On Error Resume Next
mRow = Application.Match(.Cells(i, 1), Worksheets("Sheet2").Columns(1), 0)
If mRow > 0 Then Worksheets("Sheet2").Rows(mRow).EntireRow.Delete
Next
End With
End Sub
[/VBA]
PLS DO NOT PM; OPEN A THREAD INSTEAD!!!
1) Posting Code
[CODE]PasteYourCodeHere[/CODE]
(or paste your code, select it, click # button)
2) Uploading File(s)
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.
3) Testing the Codes
always back up your files before testing the codes.
4) Marking the Thread as Solved
from Thread Tools (on the top right corner, above the first message)
That’s correct and thank you so much .
Last edited by parscon; 08-14-2012 at 04:06 PM.