How to either stop duplicate row creation or find and delete

picklefactory

Well-known Member
Joined
Jan 28, 2005
Messages
506
Office Version
  1. 365
Platform
  1. Windows
Hi folks.
I'm building a new WB and moving values via VBA from various, scattered cells on one sheet to create a single row of selected values on a 2nd sheet for charting, probably by way of a command button to run the UDF. The UDF finds the next empty row in target sheet to deposit the values from source sheet. Not sure which is the best fix, but I want to avoid the procedure being run more than once (Click happy on the button) and just creating a duplicate row/s of the same data, OR if that does happen, then search for a duplicate complete row and remove it. (Not single cell duplicates, as there can be duplicates in individual cells).
Is that difficult? I'm finding various bits of code to highlight individual duplicates when I search, but I'm struggling to find a way of defining a complete duplicate row.
Could anyone point me in the right direction please?
I'd like to add it to the UDF to either refuse to add a duplicate row, or remove it after duplication, either would work.
Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Found it!!! Yippee :LOL:
Courtesy of an old post from xld on VBA Express... works like a charm
Funny how I searched for an hour and couldn't find what I wanted.... posted my question here and then found it in ten minutes!!!

Code:
Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long
Dim rng As Range

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow
If .Evaluate("SUMPRODUCT(--(A" & i & ":A" & iLastRow & "=A" & i & ")," & _
"--(B" & i & ":B" & iLastRow & "=B" & i & ")," & _
"--(C" & i & ":C" & iLastRow & "=C" & i & "))") > 1 Then
If rng Is Nothing Then
Set rng = .Cells(i, "A").Resize(, 8)
Else
Set rng = Union(rng, .Cells(i, "A").Resize(, 8))
End If
End If
Next i

If Not rng Is Nothing Then rng.Delete

End With

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,387
Messages
6,124,633
Members
449,177
Latest member
Sousanna Aristiadou

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