Reputation: 1342
I am uploading a Tabular data into my SQL database.
The following is the original look of the data.
I want to take each temperature (Y axis) in a column and then each gravity (X Axis) in next Column, followed by the intersecting value.
Like This:
Upvotes: 2
Views: 991
Reputation: 1342
i got helped from a guy from ExcelForum. Here is the Macro Code, that solved my problem.
Option Explicit
Sub transpose_data()
Dim lrow As Long, lcol As Long, a As Long, i As Long, j As Long
Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = "Output"
a = 1
With Worksheets("Original")
lrow = .Range("A" & .Rows.Count).End(xlUp).Row
lcol = .Range("IV1").End(xlToLeft).Column
For i = 2 To lrow
For j = 2 To lcol
Worksheets("Output").Cells(a, 1).Value = .Cells(i, 1).Value
Worksheets("Output").Cells(a, 2).Value = .Cells(1, j).Value
Worksheets("Output").Cells(a, 3).Value = .Cells(i, j).Value
a = a + 1
Next j
Next i
End With
Worksheets("Output").Columns("A:C").NumberFormat = "0.00"
End Sub
Make sure to change the Sheet name to 'Original' in order to have this code working.
Upvotes: 2