Transform data to tabular format

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Transform data to tabular format

Post by YasserKhalil »

Hello everyone

I have the data in three columns. The first column is for the IDs and this will be unique in output in column A in output
The second column would be the headers after the column A in output
The third column has the values which I need to populate properly in each suitable place in the output
The attachment will explain better than the description
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Transform data to tabular format

Post by HansV »

I'm sure you can work this out for yourself.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Re: Transform data to tabular format

Post by YasserKhalil »

I am still trying but I am stuck in fact .. Really stuck

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Re: Transform data to tabular format

Post by YasserKhalil »

This is my try but I am really stuck at it

Code: Select all

Sub Test()
    Dim a, d As Object, d2 As Object, s As String, i As Long, m As Long
Dim k As Long, c As Long

    a = Range("A1:C" & Cells(Rows.Count, 1).End(xlUp).Row).Value
    ReDim b(1 To UBound(a, 1), 1 To UBound(a, 1))
    k = 1: c = 2: b(1, 1) = a(1, 1)
    Set d = CreateObject("Scripting.Dictionary")
    
    For i = 2 To UBound(a)
        If Not d.Exists(a(i, 1)) Then
            k = k + 1
            b(k, 1) = a(i, 1)
            
            d(a(i, 1)) = a(i, 2)
            
            b(1, c) = a(i, 2)
            b(k, c) = a(i, 3)
        Else
            c = c + 1
            b(1, c) = a(i, 2)
            b(k, c) = a(i, 3)
        End If
    Next i

    'Range("E10").Resize(d.Count).Value = Application.Transpose(d.keys)

End Sub
Posted at this link too
https://www.excelforum.com/excel-progra ... ost5323855" onclick="window.open(this.href);return false;

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Re: Transform data to tabular format

Post by YasserKhalil »

Is it impossible issue ..!!?
I am still stuck and I can't get it solved yet.