Results 1 to 9 of 9

Convert Horizontal Data to a Vertical Format

Threaded View

skifiend Convert Horizontal Data to a... 04-28-2018, 09:26 AM
alansidman Re: Convert Horizontal Data... 04-28-2018, 10:52 AM
skifiend Re: Convert Horizontal Data... 04-28-2018, 12:07 PM
Fluff13 Re: Convert Horizontal Data... 04-28-2018, 10:57 AM
skifiend Re: Convert Horizontal Data... 04-28-2018, 12:13 PM
Fluff13 Re: Convert Horizontal Data... 04-28-2018, 01:01 PM
sandy666 Re: Convert Horizontal Data... 04-28-2018, 01:58 PM
skifiend Re: Convert Horizontal Data... 04-28-2018, 02:14 PM
Fluff13 Re: Convert Horizontal Data... 04-28-2018, 02:21 PM
  1. #1
    Registered User
    Join Date
    10-29-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Question Convert Horizontal Data to a Vertical Format

    I have a table of data such that specific columns of the information needs to be converted from a horizontal layout and inserted below the initial row. To make things more complex any column with a value of zero needs to be ignored and each row may have a different column with a zero.

    This query is super close, but for some reason when run it on this data set it is not picking up all the horizontal data. For some reason it is stopping at column "S" rather than going to column "CZ". Also in rows where there are zeros in column "B" it does not pick up the account number and just adds the Revenue Code and Charges to the name above it (see where account 123123141 was skipped, but the object numbers were added to 123123140).

    Sub H2V()
    ' Vertically integrate horizontal revenue code data
    ' Keyboard Shortcut: Ctrl+Shift+Q
        Dim headers As Variant, names As Variant, data As Variant
        Dim iRow As Long
    
        With Worksheets("Template")
            With Intersect(.UsedRange, .Range("A:CZ"))
                headers = Application.Transpose(Application.Transpose(.Offset(, 1).Resize(1, .Columns.Count - 1).Value))
                names = Application.Transpose(.Offset(1).Resize(.Rows.Count - 1, 1).Value)
                data = .Offset(1, 1).Resize(.Rows.Count - 1, .Columns.Count - 1).Value
                .ClearContents
                .Resize(1, 3).Value = Array("Patient Number", "Rev Code", "Charges")
            End With
    
            For iRow = 1 To UBound (data)
                With .Cells(.Rows.Count, "B").End(xlUp)
                    .Offset(1, -1).Value = names(iRow)
                    .Offset(1, 0).Resize(UBound(headers)).Value = Application.Transpose(headers)
                    .Offset(1, 1).Resize(UBound(data)).Value = Application.Transpose(Application.Index(data, iRow, 0))
                End With
            Next
    
            With .Range("B3", Cells(.Rows.Count, "B").End(xlUp)).SpecialCells(xlCellTypeConstants)
                .Offset(, 1).Replace What:="0", Replacement:="", LookAt:=xlWhole
                .Offset(, 1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
            End With
        End With
    End Sub
    Raw Data:
    Data Set (horizontal).png

    Post Fix (incomplete):
    Post Fix Data Set (Vertical).png
    Attached Files Attached Files
    Last edited by jeffreybrown; 04-28-2018 at 09:55 AM. Reason: Please use code tags!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] convert the horizontal data to vertical forum
    By Pritpal Singh in forum Excel General
    Replies: 1
    Last Post: 04-06-2013, 03:35 AM
  2. [SOLVED] Macro to convert vertical data in horizontal format
    By ajang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-27-2013, 06:03 PM
  3. [SOLVED] Convert Data Vertical to Horizontal
    By dextryn in forum Excel General
    Replies: 2
    Last Post: 02-19-2013, 07:27 PM
  4. convert data horizontal to vertical
    By vorabha in forum Excel General
    Replies: 8
    Last Post: 02-10-2013, 03:53 PM
  5. convert vertical data to horizontal
    By syuk225 in forum Excel General
    Replies: 3
    Last Post: 06-14-2012, 03:58 AM
  6. Convert data From Vertical to Horizontal Format
    By reyrey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-20-2011, 03:52 PM
  7. [SOLVED] Convert Vertical row data into Horizontal
    By ajang in forum Excel General
    Replies: 8
    Last Post: 11-01-2010, 01:28 AM
  8. Convert Excel From Horizontal To Vertical Format
    By masrizam in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-13-2009, 02:29 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