Helps VBA code add "-new" to names that appear 3 times or more

Excelpromax123

Board Regular
Joined
Sep 2, 2021
Messages
172
Office Version
  1. 2010
Platform
  1. Windows
Hello Everyone. I need a piece of VBA code to filter out as described in the image below. Thank you very much!

1724659664072.png
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
It's pretty bad but it works

VBA Code:
Sub Macro1()

Dim l As Long

l = Range("A" & Rows.Count).End(xlUp).Row
With Range("C2:C" & l)
    .Value = "=IF(COUNTIF(A2:$A$2,A2)>3,A2&""-New"",A2)"
    .Copy
    .PasteSpecial xlPasteValues
End With

Application.CutCopyMode = False
End Sub
 
Upvote 0
Try. Column C is result range.
VBA Code:
Sub Add_New()
Dim A, T&, Rpt&

A = Range("A1").CurrentRegion.Offset(1, 0)
ReDim B(1 To UBound(A, 1), 1 To 1)
Rpt = 1: B(1, 1) = A(1, 1)
With CreateObject("Scripting.dictionary")
For T = 1 To UBound(A, 1) - 1
If .exists(A(T, 1)) Then .Item(A(T, 1)) = .Item(A(T, 1)) + 1 Else .Item(A(T, 1)) = 1
If .Item(A(T, 1)) <= 3 Then B(T, 1) = A(T, 1) Else B(T, 1) = A(T, 1) & "-New"
Next T
Range("C1") = "Output"
Range("C2").Resize(UBound(A, 1) - 1, 1) = B
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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