+ Reply to Thread
Results 1 to 4 of 4

Converting dataset from vertical to horizontal based on fixed criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    10-17-2014
    Location
    Shropshire, England
    MS-Off Ver
    2013
    Posts
    2

    Converting dataset from vertical to horizontal based on fixed criteria

    Hello all,

    This is my first post so apologies if anything does not quite make sense.
    I have looked at previous threads, however they do not appear to meet my needs.

    I have a vertical dataset that needs to be converted into a horizontal dataset.

    In the attached examples, Example Data 1 is showing how the spreadsheet is structured.
    Column A needs to remain vertical, however column B needs to become the column header row and column C the dataset, as demonstrated in Example 2.

    Many thanks in advance for your assistance.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Converting dataset from vertical to horizontal based on fixed criteria

    The simplest way might be to do a pivot table. Just add a header row and then use col A as the row field, B as the column field and C as the data field. Can format to remove totals etc or copy and paste values somewhere else.

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Converting dataset from vertical to horizontal based on fixed criteria

    Hi LJH2410,
    maybe something like this
    Sub ertert()
    Dim x, y(), i&, j&, k&, sp
    x = Range("A1", Cells(Rows.Count, 1).End(xlUp)).Value
    ReDim y(1 To UBound(x), 1 To 1): j = 1
    With CreateObject("Scripting.Dictionary")
        .CompareMode = 1
        For i = 1 To UBound(x)
            sp = Split(x(i, 1), ",")
            If Not .Exists(sp(1)) Then .Item(sp(1)) = sp(1): y(1, 1) = y(1, 1) & "," & sp(1)
            If .Exists(sp(0)) Then
                k = .Item(sp(0)): y(k, 1) = y(k, 1) & "," & sp(2)
            Else
                j = j + 1: .Item(sp(0)) = j: y(j, 1) = sp(0) & "," & sp(2)
            End If
        Next i
    End With
    Range("E1").Resize(j).Value = y
    End Sub

  4. #4
    Registered User
    Join Date
    10-17-2014
    Location
    Shropshire, England
    MS-Off Ver
    2013
    Posts
    2

    Re: Converting dataset from vertical to horizontal based on fixed criteria

    Thanks both for your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Special converting from Horizontal to Vertical
    By ramez in forum Excel General
    Replies: 1
    Last Post: 10-08-2014, 06:26 AM
  2. [SOLVED] Dynamic Formula based on two vertical criteria and one horizontal
    By GoGators in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-07-2013, 04:41 PM
  3. converting vertical value to horizontal within braces
    By lovinguy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-15-2011, 06:45 PM
  4. Manually add fixed vertical horizontal line to chart
    By datacruncher in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-21-2009, 08:33 AM
  5. Converting Vertical Data to Horizontal
    By josephg in forum Excel General
    Replies: 3
    Last Post: 09-16-2008, 08:38 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1