Question : Transpose-Data

Hi, Experts,
Good Morning!
I am working on an excel spreadsheet data transpose by using vba macro.
Please see attach, the sheet 1 is original data file, after click the button 'Data Transpose", the result data will be on sheet2, and data will be transposed as showed. plus the plate number will vary. how to do this?

Thanks in advance!

Answer : Transpose-Data

Hi,

try

Kris
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
Sub TransposeData()
Dim Rng As Range, r As Range, ka, Plate, k(), i As Long, c As Long, n As Long

Set Rng = Sheets("Sheet1").UsedRange.Resize(, 13).SpecialCells(2)

ReDim k(1 To Rng.Cells.Count, 1 To 4)

For Each r In Rng.Areas
    ka = r
    Plate = Trim$(Replace(ka(1, 1), "plate", "", , , vbTextCompare))
    For i = 2 To UBound(ka, 1)
        For c = 2 To UBound(ka, 2)
            If Len(ka(i, c)) Then
                n = n + 1
                k(n, 1) = n: k(n, 2) = Plate
                k(n, 3) = ka(i, 1) & ka(1, c)
                k(n, 4) = ka(i, c)
            End If
        Next
    Next
Next
With Sheets("Sheet2")
    .Range("a1:d1").Value = Array("Count", "Plate", "Position", "Data")
    .Range("a2").Resize(n, 4).Value = k
End With
End Sub
Random Solutions  
 
programming4us programming4us