Delete Repeating name and put all data in 1 row

Nandan

New Member
Joined
Mar 29, 2011
Messages
9
Dear all

I have 3 column

Name DayofApr SalofApr DaysoMay SasOfMay DaysOfJun SalofJun
X 25 15000
X 30 20000
X 15 10000

i want output like this

Name DayofApr SalofApr DaysoMay SasOfMay DaysOfJun SalofJun
X 25 15000 15 10000 30 20000

Can anybody help me

Thaks & REgards

Nandan:stickouttounge:
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,

Assuming your data in columns A B C (headers in row 1) and sorted by names in column A, maybe this
Adjust the sheet-name in the first line 0f code after the Dims

(try it on a test-workbook)

Code:
Sub arrangeData()
    'Thread 547698
    Dim wk As Worksheet
    Dim lastRow As Long, i As Long, lin As Long, col As Long
 
    Set wk = Sheets("Plan1")
 
    With wk
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
 
        'Move data
        For i = 2 To lastRow
            If .Range("A" & i).Value <> .Range("A" & i - 1) Then
                lin = i
                col = 0
            Else
                col = col + 2
                .Range("A" & lin).Offset(0, col + 1) = .Range("A" & i).Offset(0, 1)
                .Range("A" & lin).Offset(0, col + 2) = .Range("A" & i).Offset(0, 2)
            End If
        Next i
 
        'Delete rows
        For i = lastRow To 2 Step -1
            If .Range("A" & i).Value = .Range("A" & i - 1).Value Then
                .Rows(i).EntireRow.Delete
            End If
        Next i
    End With
 
End Sub

HTH

M.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

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