Multiple awards separate into different columns

michellemtzr

New Member
Joined
May 4, 2018
Messages
3
Thank you in advance.
I have a spreadsheet with participants winning multiple awards. I want the awards in separate columns tiled Awards 1 Award 2 Award 3....

I have this...

NameAward
Jane Gold
Jane Gold Plus
MarySilver
MaryBroze
MaryGold

<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>


I want this
Name Award 1Award 2Award 3
JaneGoldGold Plus
MarySilverBronzeGold

<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>
</tbody>
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Welcome to the Board!

Is the data always sorted by Name?
 
Upvote 0
Try this. You can remove the sort part if unnecessary, though it shouldn't hurt anything:
Code:
Sub MoveAwards()

    Dim rw As Long
    Dim lc As Long
    Dim c As Long
    
    Application.ScreenUpdating = False
    
'   Enter first row of data after heading
    rw = 2
    
'   Sort data
    Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlYes, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    
    Do
'       Exit loop if on last row
        If Cells(rw + 1, "A") = "" Then Exit Do
'       Check to see if value in next row of column A matches current
        If Cells(rw, "A") = Cells(rw + 1, "A") Then
'           Move up value from column B to end of current row
            Cells(rw, Columns.Count).End(xlToLeft).Offset(0, 1) = Cells(rw + 1, "B")
'           Delete row
            Rows(rw + 1).Delete
        Else
'           Move to next row
            rw = rw + 1
        End If
    Loop
    
'   Find last column with data
    lc = Range("A1").SpecialCells(xlLastCell).Column
    
'   Insert award column headings
    For c = 2 To lc
        Cells(1, c) = "Award " & c - 1
    Next c
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
How would the code change if I had a extra column

I have this
NameSportAward
Jane BasketballGold
Jane GolfGold Plus
MaryBasketballSilver
MaryBasketballBronze
MaryGolfGold

<colgroup><col><col><col></colgroup><tbody>
</tbody>


I want this
NameSportAward 1Award 2
Jane BasketballGold
Jane GolfGold Plus
MaryBasketballSilverGold
MaryGolfGold

<colgroup><col><col><col span="2"></colgroup><tbody>
</tbody>
 
Upvote 0
Try this:
Code:
Sub MoveAwards2()

    Dim rw As Long
    Dim lc As Long
    Dim c As Long
    
    Application.ScreenUpdating = False
    
'   Enter first row of data after heading
    rw = 2
    
'   Sort data by column A and column B
    Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("B1"), _
        Order2:=xlAscending, Header:=xlYes, MatchCase:=False, Orientation:=xlTopToBottom
    
    Do
'       Exit loop if on last row
        If Cells(rw + 1, "A") = "" Then Exit Do
'       Check to see if values in next row of column A and B match current
        If (Cells(rw, "A") = Cells(rw + 1, "A")) And (Cells(rw, "B") = Cells(rw + 1, "B")) Then
'           Move up value from column C to end of current row
            Cells(rw, Columns.Count).End(xlToLeft).Offset(0, 1) = Cells(rw + 1, "C")
'           Delete row
            Rows(rw + 1).Delete
        Else
'           Move to next row
            rw = rw + 1
        End If
    Loop
    
'   Find last column with data
    lc = Range("A1").SpecialCells(xlLastCell).Column
    
'   Insert award column headings
    For c = 3 To lc
        Cells(1, c) = "Award " & c - 2
    Next c
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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