VBA Code for not to Create/Copy Duplicate Rows

Gajendra72

New Member
Joined
Jun 29, 2019
Messages
2
Hi friends,

I have created a workbook of 6 sheets who's VBA code I have writted is,

Sub CopyDataBasedOnStatusCondtion()


Dim lRow, cRow As Long
lRow = Sheets("Sheet1").Range("A50000").End(xlUp).Row




For j = lRow To 1 Step -1



If Sheets("Sheet1").Range("B" & j) = "9265553826" Then
cRow = Sheets("9265553826").Range("A50000").End(xlUp).Row
Sheets("Sheet1").Rows(j).Copy Destination:=Sheets("9265553826").Range("A" & cRow + 1)


ElseIf Sheets("Sheet1").Range("B" & j) = "9978651125" Then
cRow = Sheets("9978651125").Range("A50000").End(xlUp).Row
Sheets("Sheet1").Rows(j).Copy Destination:=Sheets("9978651125").Range("A" & cRow + 1)


ElseIf Sheets("Sheet1").Range("B" & j) = "ALEO" Then
cRow = Sheets("Aleo").Range("A50000").End(xlUp).Row
Sheets("Sheet1").Rows(j).Copy Destination:=Sheets("ALEO").Range("A" & cRow + 1)


ElseIf Sheets("Sheet1").Range("B" & j) = "JASWANT" Then
cRow = Sheets("JASWANT").Range("A50000").End(xlUp).Row
Sheets("Sheet1").Rows(j).Copy Destination:=Sheets("JASWANT").Range("A" & cRow + 1)


ElseIf Sheets("Sheet1").Range("B" & j) = "ARBUDA" Then
cRow = Sheets("ARBUDA").Range("A50000").End(xlUp).Row
Sheets("Sheet1").Rows(j).Copy Destination:=Sheets("ARBUDA").Range("A" & cRow + 1)


End If
Next


End Sub

Now the issue is that whenever I click button, it creates duplicate entries/row in other 5 sheets.
Please help me to solve this issue with VBA code that it wont create duplicate entries in other sheets.

Thanks in Advance.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
One more issue,
If there s no data in Sherry's Column A or any other column till H, row doesn't get copied to relative sheet. I want that to happen.

Please help.
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,665
Members
449,045
Latest member
Marcus05

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