Change every group of rows to columns

Gregorykay

New Member
Joined
May 19, 2011
Messages
3
Hi everyone,
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

ColumnA
Name 1
Address 1
Phone 1

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

Name 2
Address 2

<o:p></o:p>

Name 3
Address 3
Phone 3
Cell 3

OUTPUT

ColumnA-----------ColumnB-----------ColumnC-----------ColumnD
Name 1--------------Adress 1- ------------Phone 1--
Name 2--------------- Adress 2<o:p></o:p>

Name 3--------------Adress 3- ------------Phone 3-------------------Cell 3<o:p></o:p>
Please help.<o:p></o:p>
<o:p> </o:p>
Thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Gregorykay,

There are several ways to solve your request, but:

What version of Excel are you using?

You will generally get much more help (and faster) in this forum if you can post your small samples (what you have and what you expect to achieve) directly in the forum.

To attach screenshots, see below in my Signature block: Post a screen shot with one of these:

If you are not able to give us screenshots, see below in my Signature block: You can upload your workbook to Box Net
 
Upvote 0
Thanks!

It looks like this<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Excel Workbook
A
18 Motel
24567898888
36536738888
47366663333
5
6Hilton
76473889384
8
9Sheraton
10
11Holiday Inn
122338767777
134355553333
Sheet1
Excel 2007

<o:p></o:p>
I want it to look like this<o:p></o:p>
Excel Workbook
ABCD
18 Motel456789888865367388887366663333
2Hilton6473889384
3Sheraton
4Holiday Inn23387677774355553333
Sheet1
Excel 2007

 
Upvote 0
Gregorykay,


Sample raw data in worksheet Sheet1 before the macro:


Excel Workbook
A
18 Motel
24567898888
36536738888
47366663333
5
6Hilton
76473889384
8
9Sheraton
10
11Holiday Inn
122338767777
134355553333
14
Sheet1





After the macro:


Excel Workbook
ABCD
18 Motel456789888865367388887366663333
2Hilton6473889384
3Sheraton
4Holiday Inn23387677774355553333
5
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, 05/19/2011
' http://www.mrexcel.com/forum/showthread.php?t=551431
Dim Area As Range, NR As Long
Application.ScreenUpdating = False
Worksheets("Sheet1").Activate
NR = 0
For Each Area In Range("A1", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants).Areas
  With Area
    NR = NR + 1
    Range("C" & NR).Resize(, .Rows.Count).Value = Application.Transpose(Area)
  End With
Next Area
Columns("A:B").Delete
ActiveSheet.UsedRange.Columns.AutoFit
Application.ScreenUpdating = True
End Sub


Before you use the macro, 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,224,520
Messages
6,179,266
Members
452,902
Latest member
Knuddeluff

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