Rows to columns

C

Chris

Hello,

I have a mailing list that is in rows rather than columns. Ie a complete
address takes up 4 rows in the same column.

Is there any way to columnize the data that I have to do a mail merge?

Chris
 
S

Sheeloo

Use the macro below;
It assumes your addresses are in Col A in Sheet1... this will write them in
Sheet2

Sub Transpose()
Dim srcSheet As String
Dim destSheet As String
Dim i, j, lastRow, step As Long

srcSheet = "Sheet1"
destSheet = "Sheet2"
step = 4

Worksheets(srcSheet).Activate

With Worksheets(srcSheet)
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

lastRow = (lastRow / step)
j = 1

For i = 1 To lastRow
Worksheets(srcSheet).Range("A" & j & ":A" & (j + step - 1)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets(destSheet).Cells(i, 1).PasteSpecial Paste:=xlPasteAll, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=True
j = j + step
Next i
End Sub
----------------------------
Procedure to run the macro
Open Excel and open the workbook with your data
Press ALT-F11 to open VB Editor
Choose Insert->Module
Paste the code
Press F5

Swich back to the workbook and verify the data in Sheet2...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top