Change every group of rows to columns

Excel4biz

New Member
Joined
Nov 7, 2012
Messages
1

I have groups of cells that are different number of rows long. What differentiates the groups is a space in between them. I would like to be able to change every row from A within a group into a new Colum. For example:
INPUT


3/S Carwash Service
4635 S. Harlem
Forest View, IL 60402
Phone:708-749-4075
Fax:N/A
A-1 High Pressure Self Serve Car Wash Equipment & Service
5226 S 132 Street
Omaha, NE 68137
Phone:402-895-5544
Fax:N/A

<tbody>
</tbody>


OUTPUT
ABCDEFG
3/S Carwash Service4635 S. HarlemForest ViewIL60402Phone:708-749-4075Fax:501-378-0102
A-1 High Pressure5226 S 132 StreetOmahaNE68137Phone:402-895-5544Fax:N/A

<tbody>
</tbody>

<tbody>
</tbody>

I'm using Excel 2011

Thanks
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Excel4biz,

Welcome to the MrExcel forum.


Sample raw data:


Excel Workbook
ABCDEFGHI
13/S Carwash Service
24635 S. Harlem
3Forest View, IL 60402
4Phone:708-749-4075
5Fax:N/A
6
7A-1 High Pressure Self Serve Car Wash Equipment & Service
85226 S 132 Street
9Omaha, NE 68137
10Phone:402-895-5544
11Fax:N/A
12
Sheet1





After the macro:


Excel Workbook
ABCDEFGHI
13/S Carwash ServiceNameAddressCityStateZipPhoneFax
24635 S. Harlem3/S Carwash Service4635 S. HarlemForest ViewIL60402708-749-4075N/A
3Forest View, IL 60402A-1 High Pressure Self Serve Car Wash Equipment & Service5226 S 132 StreetOmahaNE68137402-895-5544N/A
4Phone:708-749-4075
5Fax:N/A
6
7A-1 High Pressure Self Serve Car Wash Equipment & Service
85226 S 132 Street
9Omaha, NE 68137
10Phone:402-895-5544
11Fax:N/A
12
Sheet1





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, 11/07/2012
' http://www.mrexcel.com/forum/excel-questions/668372-change-every-group-rows-columns.html
Dim r As Long, lr As Long, nr As Long, s, t
Application.ScreenUpdating = False
Columns("C:I").ClearContents
Cells(1, 3).Resize(, 7).Value = [{"Name","Address","City","State","Zip","Phone","Fax"}]
lr = Cells(Rows.Count, 1).End(xlUp).Row
nr = 1
For r = 1 To lr Step 6
  nr = nr + 1
  Cells(nr, 3).Resize(, 2).Value = Application.Transpose(Cells(r, 1).Resize(2).Value)
  s = Split(Cells(r + 2, 1), ", ")
  Cells(nr, 5).Value = s(0)
  t = Split(s(1), " ")
  Cells(nr, 6).Resize(, 2).Value = t
  Cells(nr, 8) = Right(Cells(r + 3, 1), Len(Cells(r + 3, 1)) - 6)
  Cells(nr, 9) = Right(Cells(r + 4, 1), Len(Cells(r + 4, 1)) - 4)
Next r
Columns("C:I").AutoFit
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


Then run the ReorgData macro.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,680
Members
449,116
Latest member
HypnoFant

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