Flip data from horizontal to vertical format for uploading

Zakky

Board Regular
Joined
Mar 26, 2016
Messages
89
Hi, Is it possible to change data format in Excel. My data in excel is as follows:

Name of GL GL Code Jan-19 Feb-19 Mar-19 Apr-19......until Dec-19
Salaries 8205 $100 $200 $300 $400 $1200[/PHP][/HTML]
Tax 8206 $10 $20 $30 $40 $120

I need to show it as follows:
Salaries 8205 Jan-19 $100
Salaries 8205 Feb-19 $200
Salaries 8205 Mar-19 $300
Salaries 8205 Apr-19 $400
all twelve months going down for every GL Code as there are hundreds of different GL codes

then new GL 8206 straight after GL 8205 in a continuous rows of data
Tax 8206 Jan-19 $10
Tax 8206 Feb-19 $200
Tax 8206 Mar-19 $300
Tax 8206 Apr-19 $400


Your help would be greatly appreciated as this will save me hours of work.

Many thanks in advance
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,119
Office Version
2007
Platform
Windows
Assume your data begins in cell A1 on sheet1.
The result will remain on sheet2.

Try this

Code:
Sub Flip_data()
    Dim sh1 As Worksheet, sh2 As Worksheet, c As Range, k As Long
    Set sh1 = Sheets("Sheet1")
    Set sh2 = Sheets("Sheet2")
    sh2.Cells.Clear
    k = 2
    For Each c In sh1.Range("A2", sh1.Range("A" & Rows.Count).End(xlUp))
        For j = 3 To 14
            sh2.Cells(k, "A").Value = c
            sh2.Cells(k, "B").Value = c.Offset(, 1)
            sh2.Cells(k, "C").Value = sh1.Cells(1, j)
            sh2.Cells(k, "D").Value = sh1.Cells(c.Row, j)
            k = k + 1
        Next
    Next
    MsgBox "End"
End Sub
 

Zakky

Board Regular
Joined
Mar 26, 2016
Messages
89
I can not believe my own eyes. This works like a dream. You VBA guys are god send and have amazing skills. I'm speechless, you have no idea how much time this has saved me.

MEGA MEGA BIG THANK YOU, DanteAmor
 
Last edited:

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,119
Office Version
2007
Platform
Windows
I can not believe my own eyes. This works like a dream. You VBA guys are god send and have amazing skills. I'm speechless, you have no idea how much time this has saved me.

MEGA MEGA BIG THANK YOU, DanteAmor
Im glad to help you. I appreciate your kind words.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,071
Messages
5,484,512
Members
407,444
Latest member
Trick

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top