Macro to work with duplicate values in rows.

mkrlhd

New Member
Joined
Mar 7, 2018
Messages
3
I need your help to build a Macro that do this...

The problem:

[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD="align: center"]702[/TD]
[TD="align: center"]12345[/TD]
[/TR]
[TR]
[TD="align: center"]702[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]VSA[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]702[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]6A[/TD]
[TD="align: center"]12346[/TD]
[/TR]
[TR]
[TD="align: center"]CKM[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]CKM[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]701[/TD]
[TD="align: center"]12378[/TD]
[/TR]
[TR]
[TD="align: center"]701[/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]

















The solution:

[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD="align: center"]702,VSA[/TD]
[TD="align: center"]12345[/TD]
[/TR]
[TR]
[TD="align: center"]6A, CKM[/TD]
[TD="align: center"]12346[/TD]
[/TR]
[TR]
[TD="align: center"]701[/TD]
[TD="align: center"]12378[/TD]
[/TR]
</tbody>[/TABLE]

 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
How about
Code:
Sub ConcatUnique()
   Dim Rng As Range
   Dim Dic As Object
   Dim Cl As Range
   
   Set Dic = CreateObject("scripting.dictionary")
   For Each Rng In Range("B:B").SpecialCells(xlBlanks).Areas
      For Each Cl In Rng.Offset(-1, -1).Resize(Rng.Count + 1)
         If Not Dic.exists(Cl.Value) Then Dic.Add Cl.Value, Nothing
      Next Cl
      Rng.Offset(-1, -1).Resize(1).Value = Join(Dic.keys, ",")
      Dic.removeall
   Next Rng
   Range("B:B").SpecialCells(xlBlanks).EntireRow.Delete
      
End Sub
 
Upvote 0
Glad t help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,612
Members
452,660
Latest member
Zatman

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