Need urgent help in excel .

New Contributor

Column A has same value but column B has different value . 

e.g. 236445 has 3 different email ID . can some one help me to put those columns in different columns 

 

236445karthik.shekar@test.co.in     
236445vikram.shetty@test.co.in     
236445murugesan.shanmugam@test.co.in     
210406gagan.desai@test.co.in     
210406vikram.shetty@test.co.in     
210406sujith.vijayan@test.co.in     
210406jeevesh.mehta@test.co.in     
210406mithun.vesuwala@test.co.in     
210406rakesh.kartemp@test.co.in     
       
I need it as below . Can anyone help ?    
       
236445karthik.shekar@test.co.in     
236445 murugesan.shanmugam@test.co.in   
210406gagan.desai@test.co.in     
210406 vikram.shetty@test.co.in    
210406  sujith.vijayan@test.co.in   
210406   jeevesh.mehta@test.co.in  
210406    mithun.vesuwala@test.co.in 
210406     rakesh.kartemp@test.co.in
3 Replies

@Avishant 

Here is a macro:

Sub MoveB()
    Dim r As Long
    Dim m As Long
    Dim c As Long
    Application.ScreenUpdating = False
    m = Cells(Rows.Count, 1).End(xlUp).Row
    c = 2
    For r = 2 To m
        If Cells(r, 1).Value = Cells(r - 1, 1).Value Then
            c = c + 1
            Cells(r, 2).Cut Destination:=Cells(r, c)
        Else
            c = 2
        End If
    Next r
    ' Optional
    ActiveSheet.UsedRange.EntireColumn.AutoFit
    Application.ScreenUpdating = True
End Sub

@Hans Vogelaar  can this be possible on excel ?  I do not know macros 

@Avishant 

Press Alt+F11 to activate the Visual Basic Editor.

Select Insert > Module to create a new code module.

Copy the code from my previous reply and paste it into the module.

With the insertion point anywhere in the code, press F5 to run the macro.

Switch back to Excel to view the result.

If you want to keep the macro, save the workbook as a macro-enabled workbook (.xlsm)