+ Reply to Thread
Results 1 to 3 of 3

Retrieve Column Headers Dynamically - Based on column Values

Hybrid View

  1. #1
    Registered User
    Join Date
    04-16-2015
    Location
    India
    MS-Off Ver
    2010
    Posts
    5

    Retrieve Column Headers Dynamically - Based on column Values

    There is a table with over 100 columns with unique headers. Each column data corresponds to a percentage associated with the user. I need to create a consolidation of just {user}{column header + percentage} so that it is easy for others to understand which all tasks does the user contribute to. I have attached the input and proposed output to this issue. Kindly help
    Attached Files Attached Files

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Retrieve Column Headers Dynamically - Based on column Values

    Hi, Try this code

    Sub DataTransposition()
    
        Dim Arr, NewArr(), C1 As Integer, C2 As Integer, I As Byte, LR As Integer, Coll As Collection: Set Coll = New Collection
        
        Range("A4").End(xlDown).Offset(3).CurrentRegion.ClearContents
        
        Arr = Range(Cells(4, 1), Cells(Range("A4").End(xlDown).Row, Range("A4").End(xlToRight).Column))
        
        For C1 = LBound(Arr) + 1 To UBound(Arr)
            I = 1
            For C2 = LBound(Arr, 2) + 1 To UBound(Arr, 2)
                If Arr(C1, C2) <> 0 Then
                    ReDim Preserve NewArr(I)
                    NewArr(0) = Arr(C1, 1)
                    NewArr(I) = Arr(1, C2) & ":" & Format(Arr(C1, C2), "0.00%")
                    I = I + 1
                End If
            Next C2
            Coll.Add Join(NewArr, "|")
        Next C1
        
        LR = Cells(Rows.Count, 1).End(xlUp).Row + 1: ReDim NewArr(0): I = 1
        
        For C1 = 1 To Coll.Count
            I = I + 1
            NewArr(0) = VBA.Split(Coll(C1), "|")
            For C2 = 0 To UBound(NewArr(0))
                Cells(LR + I, C2 + 1).Value = NewArr(0)(C2)
            Next C2
        Next C1
        
    End Sub
    Please see the file attached.
    Attached Files Attached Files
    Last edited by NeedForExcel; 04-12-2016 at 05:51 AM.
    Cheers!
    Deep Dave

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Retrieve Column Headers Dynamically - Based on column Values

    ARRAY formula In B19, then dragged across
    =IFERROR(INDEX($B$4:$L$4&":"&INDEX(ROUND($B$5:$L$14,2)*100,MATCH($A25,$A$5:$A$14,0),)&"%",SMALL(IF(INDEX(ROUND($B$5:$L$14,2),MATCH($A25,$A$5:$A$14,0),)>0,COLUMN($B$5:$L$5),""),COLUMN(A$1))-COLUMN($B$2)+1),"")
    ARRAY formula should be confirmed with Ctrl+Shift+Enter Keys together.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 08-10-2015, 09:58 AM
  2. Dynamically calculating a record ID in one column based on values in others
    By yewhanbaker in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-22-2015, 02:28 PM
  3. Need help pulling column headers based on table values (not max or min)
    By red5030 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-08-2014, 10:45 AM
  4. Macro to copy row values based on a identical column headers
    By Vijaya Pratap in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-25-2013, 04:12 AM
  5. [SOLVED] Return Column Headers based on row rank with duplicate values in row
    By carlwin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-31-2013, 12:24 AM
  6. [SOLVED] How to select from a table of values based upon column and row headers
    By Peteryoull in forum Excel General
    Replies: 4
    Last Post: 07-30-2012, 05:58 AM
  7. Need help in comparing two sheets based on a column value and retrieve row values
    By balajiranganathan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-15-2010, 02:49 AM

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