Forum

VBA Convert Two to ...
 
Notifications
Clear all

VBA Convert Two to Many (seven specifically)

5 Posts
3 Users
0 Reactions
65 Views
(@webbers)
Posts: 147
Estimable Member
Topic starter
 

I have been trying to figure this one out, and I am at a loss.  There are over 14K rows of data, so doing this manually is NOT an option.  I have attached a spreadsheet with 2 tabs, named "before" and "after".

  • Before indicates how I receive the data.  Users are listed in Column B.  These users are listed multiple times for each role they have.  The roles are listed in Column D.  A user could have as many as 7 roles maximum.
  • After shows how I need this data to display.  There should only be one record for each user, and there would be Role columns 1-7 Columns D-H.

I know there must be a way to do this in VBA, but I just cannot figure it out.  Any help is greatly appreciated.

 
Posted : 18/03/2023 1:19 pm
(@keebellah)
Posts: 373
Reputable Member
 

Hi, which version of Excel are you using?

How's your VBA knwoledge?

 
Posted : 18/03/2023 4:33 pm
(@keebellah)
Posts: 373
Reputable Member
 

This is done without VBA but will only work with 365 or 2021

 
Posted : 19/03/2023 3:08 am
Riny van Eekelen
(@riny)
Posts: 1185
Member Moderator
 

Alternatively, use Power Query, as shown in the attached file.

 
Posted : 19/03/2023 3:59 am
(@webbers)
Posts: 147
Estimable Member
Topic starter
 

@Hans Hallebeek,

Thanks for the well detailed answer.  I was able to easily apply the logic you defined to my live file.  I added an IF Statement so it did not display the zeros.

 

@Riny van Eekelen,

I have downloaded your PQ workbook so I can also learn that way to get to the answer.  I love PQ!!!!

 
Posted : 21/03/2023 12:05 pm
Share: