Transposing a large data set in a single column to multiple rows

moonsketcher

New Member
Joined
Jun 7, 2016
Messages
5
Hello :)

I have a long single column of data, that I need to transpose and have each new section separated onto a new row. (I realize that description is really confusing, I have included an example below)

Data TypeLarge Column of Data
Name:
Mark
Address: 123 Roadname here
City/State: Columbus, Ohio
Phone: 555.555.5555
Name:
John
Address: 456 Roadtest Rd
City/State: San Diego, California
Phone: 555.555.5555
Name: Tom
Address: 456 Testing Ct
City/State:
Seattle, Washington
Phone: 555.555.5555
Name:Bob
Address:123 Excel Way
City/State:Castlerock, Maine
Phone:555.555.5555

<tbody>
</tbody>


And I'm trying to set a template so that the data (when pasted into the sheet) is auto formatted in a separate sheet to look like this:

NameAddressCity/StatePhone
Mark123 Roadname hereColumbus, Ohio555.555.5555
John456 Roadtest RdSan Diego, California555.555.5555
Tom456 Testing CtSeattle, Washington555.555.5555
Bob123 Excel WayCastlerock, Maine555.555.5555

<tbody>
</tbody>

Obviously, this is false data. The data I'm working with is sensitive so I can't paste it here.

I have the distinct feeling I am overthinking it, but after days of beating my head against the wall, I am finally giving in and asking for help. I have hunted all over the web and this site, but I think in the process of overthinking - that I am missing some key search phrase to have the magical answer handed to me.

The =Transpose function will not work because it requires extra key strokes. And no break for the next row.

I am making a simple template for EU to utilize to paste in data and have it automatically formatted accordingly.

Any help that anyone could offer would be greatly appreciated.

Please and thank you in advance.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Assuming your original begins in A1 including headers, use this formula in C2 and Fill Across and down.
Code:
=INDIRECT("R"&(ROW()-2)*4+COLUMN()-1&"C2",FALSE)
 
Upvote 0
Assuming your original begins in A1 including headers, use this formula in C2 and Fill Across and down.
Code:
=INDIRECT("R"&(ROW()-2)*4+COLUMN()-1&"C2",FALSE)


That works really great for the example data, so I'm partially there.

The problem is that the real data is not always exactly 4 rows long. Sometimes it could be 5 or 6 rows long. So in my perfect world where I am asking for the moon....I would need it to identify "Name" as the starting text to hunt for. Then auto fill from there. Hit the next name, drop down a line then auto fill.

I hope that makes sense.

And if I can't do it, so be it.

FYI, I cheered OUT LOUD and scared the crap out of my dogs when I tested it and it worked on my example data. So thank you very much.
 
Upvote 0
at work now but I have a concept in my brain to "flesh out" after work.
I'm in USA central time....
 
Upvote 0
...The problem is that the real data is not always exactly 4 rows long. Sometimes it could be 5 or 6 rows long. So in my perfect world where I am asking for the moon....I would need it to identify "Name" as the starting text to hunt for. Then auto fill from there. Hit the next name, drop down a line then auto fill.

Are the Header names always the same 4-6 item names?
 
Upvote 0
Yep, always the same header names. Just not necessarily always the same amount of fields.

Thank you so much for your help.
 
Upvote 0
Can you list the possible field names (or reasonable substitutes) ?
 
Upvote 0
Again, assuming your source data with headers begins in Cell A1.
Copy the possible Headers in C1:H1
In C2 paste the following formula
Code:
=IF($A2=$A$2,VLOOKUP(C$1,$A2:$B8,2,FALSE),"")
Fill Across and Down.

Makes the assumption there are a minimum of 4 fields per name and no more than 6 fields per name.

(Okay, so I took lunch at my desk.)
 
Upvote 0
moonsketcher,

Welcome to the MrExcel forum.

Here is a macro solution for you to consider, that uses two arrays in memory, that will adjust to the varying number of raw data rows.

I assume that both worksheets exist, and, that both have titles in row 1.

You can change the worksheet names in the macro.

Sample worksheets before the macro:


Excel 2007
AB
1Data TypeLarge Column of Data
2Name:Mark
3Address:123 Roadname here
4City/State:Columbus, Ohio
5Phone:555.555.5555
6Name:John
7Address:456 Roadtest Rd
8City/State:San Diego, California
9Not This1:Not This1:
10Phone:555.555.5555
11Name:Tom
12Address:456 Testing Ct
13Not This1:Not This1:
14City/State:Seattle, Washington
15Not This2:Not This2:
16Phone:555.555.5555
17Name:Bob
18Not This1:Not This1:
19Not This2:Not This2:
20Address:123 Excel Way
21Not This3:Not This3:
22City/State:Castlerock, Maine
23Phone:555.555.5555
24
Sheet1



Excel 2007
ABCD
1NameAddressCity/StatePhone
2
3
4
5
6
Sheet2


And, after the macro:


Excel 2007
ABCD
1NameAddressCity/StatePhone
2Mark123 Roadname hereColumbus, Ohio555.555.5555
3John456 Roadtest RdSan Diego, California555.555.5555
4Tom456 Testing CtSeattle, Washington555.555.5555
5Bob123 Excel WayCastlerock, Maine555.555.5555
6
Sheet2


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
2. Open your NEW 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
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub ReorgData()
' hiker9, 06/08/2016, ME945802
Dim w1 As Worksheet, wr As Worksheet
Dim a As Variant, i As Long
Dim o As Variant, j As Long
Dim n As Long, nr As Long
Application.ScreenUpdating = False
Set w1 = Sheets("Sheet1")   '<-- you can change the sheet name here
Set wr = Sheets("Sheet2")   '<-- you can change the sheet name here
a = w1.Range("A2:B" & w1.Range("A" & Rows.Count).End(xlUp).Row)
n = Application.CountIf(w1.Columns(1), "Name:")
ReDim o(1 To n, 1 To 4)
For i = 1 To UBound(a, 1)
  Select Case a(i, 1)
    Case "Name:"
      j = j + 1: o(j, 1) = a(i, 2)
    Case "Address:"
      o(j, 2) = a(i, 2)
    Case "City/State:"
      o(j, 3) = a(i, 2)
    Case "Phone:"
      o(j, 4) = a(i, 2)
    Case Else
      'do nothing
  End Select
Next i
With wr
  nr = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
  .Cells(nr, 1).Resize(UBound(o, 1), UBound(o, 2)) = o
  .Columns(1).Resize(, 4).AutoFit
  .Activate
End With
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the ReorgData macro.
 
Upvote 0
Sadly, I can't use a macro for this. I need to be able to ship it to EU and macro enabled docs get stripped out. But thank you very much for your help, I did save this for reference sakes.
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

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