Date from Horizontal to Vertical

christianbiker

Active Member
Joined
Feb 3, 2006
Messages
379
Hi all,

I have a spreadsheet that tracks individuals including names, address & contact information. The information is stored horizontally across the spreadsheet but I am wondering if there is a) a way using formulas to chunk this data together vertically based on each person, or b) a vba code that does the same. I have included an example below with horizonatal data and an example of what I would like it to look like horizontally.

Thanks for any assistance.
Excel Workbook
BCDEFGHIJ
2LAST NAMEFIRST NAME(S)KID(S) NAMESSTREET (Apt/Unit, No., Street)CITYP. CODEHOMEWORKCELL
3KingJim & Dawn15 Prospect St.TorontoLW5 1W6555-555-5555555-555-5555555-555-5555
4MorningstarTim & LisaJohnathon, Bethany, Kimberly, Alexander21 King St.St. CatharinesLW5 1W5555-555-5555555-555-5555555-555-5555
5RogersEd & JaniceWilliam, Faith18 Main St.MississaugaLW5 1W6555-555-5555
6
7
8KingMorningstar
9Jim & DawnTim & Lisa
1015 Prospect St.21 King St.
11TorontoSt. Catharines
12LW5 1W6LW5 1W5
13555-555-5555555-555-5555
14555-555-5555555-555-5555
15555-555-5555555-555-5555
DATABASE
Excel 2003
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Looks like you just need to select range - copy - then under paste choose transpose
 
Upvote 0
I have tried the transponse function and ran into a problem. The Last Name & First Name remain separate from each other. For purposes elsewhere that needs to say the same. I am thinking of add a hiddine column that joins the two so I think I would prefer VBA code rather than a formula in order to avoind having to unhide and then rehide the column.

The other thing I noticed with Transpose is that it just plops everything on a horizontal plain, but I need to have x number on 1 level, then go to the next level and so on. I need to be able to print this as a directory so going all the way to the right without end is no good. I would also like to have a separating column & row between each person.

And I did leave out the kids...with a hidden column I can bypass that. I could also leave it in I suppose.

Thanks!
 
Upvote 0
Try this in the sheet code - you can make appropriate changes - just click a row and it will process that row

Code:
Option Compare Text
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With ActiveSheet.UsedRange
        ColLast = .Columns(.Columns.Count).Column
    End With
    Dim MyValues()
    If ActiveCell.Row >= 3 Then
        Along = 0
        For i = 2 To ColLast
            If ActiveSheet.Cells(ActiveCell.Row, i) <> vbNullString And ActiveSheet.Cells(2, i) <> "KID(S) NAMES" Then
                Along = Along + 1
            End If
        Next i
        ReDim MyValues(Along)
        Along = 0
        For i = 1 To ColLast
            If ActiveSheet.Cells(ActiveCell.Row, i) <> vbNullString And ActiveSheet.Cells(2, i) <> "KID(S) NAMES" Then
                MyValues(Along) = ActiveSheet.Cells(ActiveCell.Row, i)
                Along = Along + 1
            End If
        Next i
        For i = 0 To UBound(MyValues)
            ActiveSheet.Cells(i + 8, ActiveCell.Row - 2) = MyValues(i)
        Next i
    End If
End Sub
 
Upvote 0
Thanks for your help Rasm...this isn't quite what I am looking to do.

What I would like to have is a macro button as the controller of the Sub, not the clicking on a cell. I would also like the data to be transposed to another worksheet as this one sorts it on the same worksheet. Some ranges have blank cells and I would like it to automatically delete them when transposing. I have included below a before and after view in the hope this will help. The data from thefirst example is found on a worksheet called "DATABASE" and the data from the second example is on a worksheet called "DETAILED DIRECTORY".

EXAMPLE 1 - DATA SOURCE
Excel Workbook
EFGHI
3Clark, Jim32 Wilson St.TownsendLW5 1W6
4King, Chris & Mary15 Prospect St.TorontoLW5 1W6555-555-5555
5Knoop, Oliver
6Morningstar, Rob & Lisa21 King St.St. CatharinesLW5 1W5555-555-5555
7Snodgrass, Mark & Ruth18 Main St.MississaugaLW5 1W6555-555-5555
8Turner, Tim & Lisa5 Main St.BramptonLW5 1W6
DATABASE
Excel 2003
Cell Formulas
RangeFormula
E3=IF(M3="YES", B3 & ", " & C3,"")
E4=IF(M4="YES", B4 & ", " & C4,"")
E5=IF(M5="YES", B5 & ", " & C5,"")
E6=IF(M6="YES", B6 & ", " & C6,"")
E7=IF(M7="YES", B7 & ", " & C7,"")
E8=IF(M8="YES", B8 & ", " & C8,"")


EXAMPLE 2 - FINISHED DATA
Excel Workbook
ABCDE
1Clark, MarkKing, Chad & JulieKnoop, Oliver
232 Wilson St.15 Prospect St.
3TownsendToronto
4LW5 1W6LW5 1W6
5555-555-5555
6
7Morningstar, Rob & LisaSnodgrass, Dave & RuthTurner, Rick & Mary Ann
821 King St.18 Main St.5 Timberglade Dr.
9St. CatharinesMississaugaBrampton
10LW5 1W5LW5 1W6LW5 1W6
11555-555-5555555-555-5555
DETAILED DIRECTORY
Excel 2003

Thanks,
Chad
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,522
Members
452,923
Latest member
JackiG

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