Help to reorganise data in a table please

jab40

New Member
Joined
Mar 1, 2011
Messages
19
Hi -- could anyone help me?

I have a table that essentially looks like this:

A B C
App # Spons 1. Spons 2.

1 App1 Bob Joe
2 App2 Joe Susan
3 App3 Susan Bob
4 App4 Bob Joe
5 App5 Bob Susan

And I want to get the data into this format:

A B C D E
Name 1 2 3 4

1 Bob: App1 App3 App4 App5
2 Joe App1 App2 App4
3 Susan App2 App3 App5

Is there a way I can set up a spreadsheet with a set of formulae to basically search the first spreadsheet and return the information in the format shown in the second?

Hope this makes sense, and thanks for your help.

**Edit: Okay this didn't seem to make sense as I had hoped. Basically the first spreadsheet lists all the applications in the first column, and the two sponsors of each in the second and third column. I want to have a spreadsheet with each of the sponsors' names in the first column, and the applications they are sponsoring in the next columns.
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
jab40,


Sample raw data in worksheet Sheet1:


Excel Workbook
ABCD
1App #Spons 1.Spons 2.
2App1BobJoe
3App2JoeSusan
4App3SusanBob
5App4BobJoe
6App5BobSusan
7
Sheet1





After the macro in new worksheets:


Excel Workbook
ABCDE
1App1App3App4App5
2
Bob





Excel Workbook
ABCD
1App1App2App4
2
Joe





Excel Workbook
ABCD
1App2App3App5
2
Susan





If you ran the macro again your would get in worksheet Bob:


Excel Workbook
ABCDEFGHI
1App1App3App4App5App1App3App4App5
2
Bob





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Sub ReorgData()
' hiker95, 06/21/2011
' http://www.mrexcel.com/forum/showthread.php?t=565903
Dim w1 As Worksheet, ws As Worksheet
Dim LR As Long, LR2 As Long, a As Long, aa As Long, LC As Long, wLC As Long
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
LR = w1.Cells(Rows.Count, 1).End(xlUp).Row
LC = w1.Cells(1, Columns.Count).End(xlToLeft).Column
For a = 2 To LR Step 1
  For aa = 2 To LC Step 1
    If Not Evaluate("ISREF(" & w1.Cells(a, aa) & "!A1)") Then Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = w1.Cells(a, aa).Value
    Set ws = Worksheets(w1.Cells(a, aa).Value)
    wLC = ws.Cells(1, Columns.Count).End(xlToLeft).Column
    If wLC = 1 And ws.Cells(1, 1) = "" Then
      wLC = 1
    Else
      wLC = wLC + 1
    End If
    ws.Cells(1, wLC).Value = w1.Cells(a, 1).Value
  Next aa
Next a
w1.Activate
Application.ScreenUpdating = True
End Sub


Then run the ReorgData macro.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,337
Members
452,907
Latest member
Roland Deschain

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