Automated Transposition

hotblooded

New Member
Joined
May 31, 2010
Messages
11
Hello All,

I need help transposing some data from one column into rows, as necessary. It's probably easier to show you. I have this:

Mary Smith

123 W Main St

NC

Charlotte NC

Joe Smith

321 Broad St

CA

San Jose Ca


And want this:


Mary Smith 123 W Main St NC Charlotte NC
Joe Smith 321 Broad St CA San Jose Ca


Any ideas?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
hotblooded,

Can we have screenshots of your data (before and after)?


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
This is what I have:
Excel Workbook
A
1Mary Smith
2
3123 W Main St
4
5NC
6
7Charlotte NC
8
9Joe Smith
10
11321 Broad St
12
13CA
14
15San Jose Ca
Sheet1
Excel 2010

This is what I want:
Excel Workbook
GHIJ
8Mary Smith123 W Main StNCCharlotte NC
9Joe Smith321 Broad StCASan Jose Ca
Sheet1
Excel 2010

I am working in Excel 2010
 
Last edited:
Upvote 0
hotblooded,


Sample raw data:


Excel Workbook
ABCDEFGHIJ
1Mary Smith
2
3123 W Main St
4
5NC
6
7Charlotte NC
8
9Joe Smith
10
11321 Broad St
12
13CA
14
15San Jose Ca
16
Sheet1





After the macro:


Excel Workbook
ABCDEFGHIJ
1Mary Smith
2
3123 W Main St
4
5NC
6
7Charlotte NC
8Mary Smith123 W Main StNCCharlotte NC
9Joe SmithJoe Smith321 Broad StCASan Jose Ca
10
11321 Broad St
12
13CA
14
15San Jose Ca
16
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, 04/19/2011
' http://www.mrexcel.com/forum/showthread.php?t=544475
Dim LR As Long, a As Long, NR As Long
Application.ScreenUpdating = False
LR = Cells(Rows.Count, 1).End(xlUp).Row
NR = 7
For a = 1 To LR Step 8
  NR = NR + 1
  Cells(NR, "G") = Cells(a, 1)
  Cells(NR, "H") = Cells(a + 2, 1)
  Cells(NR, "I") = Cells(a + 4, 1)
  Cells(NR, "J") = Cells(a + 6, 1)
Next a
Columns("G:J").AutoFit
Application.ScreenUpdating = True
End Sub



Before you run the macro, save your workbook, Save As, a macro enabled workbook.


Then run the ReorgData macro.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,628
Members
452,933
Latest member
patv

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