livetolearn4life
New Member
- Joined
- Jul 14, 2020
- Messages
- 15
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
Hello everyone
so what im trying to do , is if Cell A:A has duplicate value then take value in J and L and move them up on the same row as the first instance in column A then remove the duplicates rows.
im am close with this code it's just that but i can't figure the last part of out.
so what im trying to do , is if Cell A:A has duplicate value then take value in J and L and move them up on the same row as the first instance in column A then remove the duplicates rows.
im am close with this code it's just that but i can't figure the last part of out.
VBA Code:
Sub SPIN()
Dim Ary As Variant, Nary As Variant
Dim r As Long, nr As Long, c As Long
Sheets("RAW DATA").Select
Ary = Sheets("RAW DATA").Range("A1").CurrentRegion.Value2
ReDim Nary(1 To UBound(Ary), 1 To 12)
For r = 2 To UBound(Ary)
If Ary(r, 1) <> Ary(r - 1, 1) Then
nr = nr + 1
For c = 1 To 12
Nary(nr, c) = Ary(r, c)
Next c
Else
Nary(nr, 12) = Nary(nr, 12) & ", " & Ary(r, 12)
End If
Next r
Sheets("WHAT I NEED").Select
Sheets("WHAT I NEED").Range("A2").Resize(nr, 12).Value = Nary
End Sub
|
Last edited by a moderator: