View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Need help changing rows into columns

Assumptions:
source data has no blank rows in the data.
all blocks of addresses have the same number of rows with labels in the same
location
the source data is the first worksheet in the workbook. The destination
sheet is the second sheet in the workbook

do Alt+F11 which takes you to the VBE. in the menu do Insert=Menu

paste in this code. Do Alt+F11 to return to Excel

go to Tools=Macro=Macros, select ABCD, click Run.


Sub ABCD()
Dim rw1 As Long, rw2 As Long
Dim col2 As Long, Sh1 As Worksheet
Dim sh2 As Worksheet, bDone As Boolean
rw1 = 1
rw2 = 2
col2 = 1
Set Sh1 = Worksheets(1)
Set sh2 = Worksheets(2)
bDone = False
Do While Not IsEmpty(Sh1.Cells(rw1, 1))
If InStr(1, Sh1.Cells(rw1, 1), _
"Name", vbTextCompare) And rw1 < 1 Then
bDone = True
rw2 = rw2 + 1
col2 = 1
End If
If Not bDone Then sh2.Cells(1, col2).Value = _
Sh1.Cells(rw1, 1).Value
sh2.Cells(rw2, col2).Value = _
Sh1.Cells(rw1, 2).Value
rw1 = rw1 + 1
col2 = col2 + 1
Loop

End Sub

--
Regards,
Tom Ogilvy


"wstaylor81" wrote
in message ...



Ok, so I'm kind of a beginner at this and I need a little more hand
holding if I'm gonna figure this out. I'm going to give you exactly the
info that I'm working with and I'm gonna hope that you can give me the
same instruction, just tailored to a beginner. Here is a listings that
looks exactly like what I am copying and pasting into excel.

Column A Column B

Name_______Brian
Title________Dr.
Address_____1 hoover drive
City________Atlantis
State_______Kansa
Zip_________12345
Country_____USA
Phone______23423423
Fax________32425345

Name... etc.

Then it continues with another one below, and goes on for about a
mile.

I need to know what I need to type, and where I need to type it in
order to turn a list like this into a nice neat spreadsheet with the
headings(name, title, etc.) at the top of each column and the correct
information under each heading. Thank you for helping me figure this
out.

Will


--
wstaylor81
------------------------------------------------------------------------
wstaylor81's Profile:

http://www.excelforum.com/member.php...o&userid=29495
View this thread: http://www.excelforum.com/showthread...hreadid=491931