How to Transpose Results Horizontally

andyka

Board Regular
Joined
Sep 20, 2021
Messages
52
Office Version
  1. 2019
Platform
  1. Windows
Is it possible to transpose the data horizontally as shown in table on right. i tried various method but has been unsuccessfull. i am looking for formula version. Please help.
Stage Gates Report.xlsx
ABCDEFGHIJKLMNO
1Results I want to see
2
3Activity IDStartFinishSTAGE GATE 1STAGE GATE 2STAGE GATE 3STAGE GATE 4STAGE GATE 5
4P116/03/2326/02/27P116/03/2316/03/2303/08/2303/08/23
5STAGE GATE 116/03/2316/03/23P221/07/2321/07/23
6STAGE GATE 203/08/2303/08/23P613/09/2313/09/2327/06/2427/06/24
7STAGE GATE 320/03/2520/03/25P717/02/2317/02/2327/11/2327/11/23
8STAGE GATE 429/09/2629/09/26P823/02/2423/02/2425/11/2425/11/24
9STAGE GATE 526/02/2726/02/27P518/10/2318/10/2301/08/2401/08/24
10P221/07/2322/10/26P9
11STAGE GATE 221/07/2321/07/23P1024/10/2324/10/23
12STAGE GATE 313/12/2413/12/24
13STAGE GATE 401/06/2601/06/26
14STAGE GATE 522/10/2622/10/26
15P613/09/2311/11/27
16STAGE GATE 113/09/2313/09/23
17STAGE GATE 227/06/2427/06/24
18STAGE GATE 326/11/2526/11/25
19STAGE GATE 421/06/2721/06/27
20STAGE GATE 511/11/2711/11/27
21P717/02/2324/08/27
22STAGE GATE 117/02/2317/02/23
23STAGE GATE 227/11/2327/11/23
24STAGE GATE 307/05/2507/05/25
25STAGE GATE 431/03/2731/03/27
26STAGE GATE 524/08/2724/08/27
27P823/02/2414/02/28
28STAGE GATE 123/02/2423/02/24
29STAGE GATE 225/11/2425/11/24
30STAGE GATE 320/05/2620/05/26
31STAGE GATE 415/09/2715/09/27
32STAGE GATE 514/02/2814/02/28
33P518/10/2325/11/27
34STAGE GATE 118/10/2318/10/23
35STAGE GATE 201/08/2401/08/24
36STAGE GATE 319/03/2619/03/26
37STAGE GATE 405/07/2705/07/27
38STAGE GATE 525/11/2725/11/27
39P915/09/2327/03/25
40STAGE GATE 315/09/2315/09/23
41STAGE GATE 428/10/2428/10/24
42STAGE GATE 527/03/2527/03/25
43P1024/10/2320/07/26
44STAGE GATE 224/10/2324/10/23
45STAGE GATE 330/10/2430/10/24
46STAGE GATE 420/02/2620/02/26
47STAGE GATE 520/07/2620/07/26
Sheet1
Cell Formulas
RangeFormula
F4F4=IFERROR(INDEX($B$4:$B$1000,MATCH($E4,$A$4:$A$1000,0)+MATCH(F$3,$F$3,0)-1),"")
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Are there any experts who may be able to offer a solution to my problem?
 
Upvote 0
Are you able to have the P1, P2 etc in a seperate column, the first column?
 
Upvote 0
I ideally, no because this is how i get my RAW data extracted from another software. and its easy just to update my dates in column B and C from RAW DATA file.
 
Upvote 0
Can we see how your raw data is strutured?
exactly the same way as it shown in my post the only difference is i have over 1200 rows with additional activities and its in CSV format
 
Upvote 0
Can we see how your raw data is strutured?
Any Solution Yet Herakles. I looked everywhere for solution but could not find it. it seems to be really tricky. Your help would be highly appreciated.
 
Upvote 0
Lets hope that this will work for you.

It assumes that you have nothing to the right of the results and that your data is on Sheet1.

Put this into a standard code module.

Test it on a copy of your data.

If you have not got a row set up for a P number or a column set up for a Stage Gate number it will warn you and then
abort the procedure.

VBA Code:
Public Sub subTranspose()
' https://www.mrexcel.com/board/threads/how-to-transpose-results-horizontally.1234004/#post-6042705
Dim rngData As Range
Dim arr() As Variant
Dim i As Integer
Dim intRow As Integer
Dim strP As String
Dim rngFound As Range
Dim rngRow As Range
Dim rngColumn As Range
Dim Ws As Worksheet

On Error GoTo Err_Handler

    ActiveWorkbook.Save

    Set Ws = Worksheets("Sheet1")
    
    Set rngData = Ws.Range("A3:C" & Range("A1").End(xlDown).Row)
        
    arr = rngData
    
    Ws.Activate
    
    Ws.Range("F4:AZ10000").Value = ""
    
    intRow = 4
    
    For i = LBound(arr) To UBound(arr)
    
        If Left(arr(i, 1), 1) = "P" Then
            strP = arr(i, 1)
            Set rngRow = Ws.Range("E4:E500").Find(strP, LookIn:=xlValues)
            If rngRow Is Nothing Then
                MsgBox "Cannot find a row for " & strP, vbCritical, "Warning!"
            End If
            intRow = intRow + 1
        Else
            Set rngColumn = Ws.Range("E3").Resize(1, 50).Find(arr(i, 1), LookIn:=xlValues)
            If rngColumn Is Nothing Then
                MsgBox "Cannot find a column for " & arr(i, 1), vbCritical, "Warning!" & " " & Ws.Range("E3").Resize(1, 50).Address
            End If
            Ws.Cells(intRow, rngColumn.Column).Resize(1, 2).Value = Array(arr(i, 2), arr(i, 3))
        End If
        
    Next i
    
    MsgBox "The data has been transposed.", vbInformation, "Confirmation"
    
Exit_Handler:
    
    Exit Sub
    
Err_Handler:
    
   MsgBox Err.Number & " " & Err.Description
   
   Resume Exit_Handler
    
End Sub
 
Upvote 0
Lets hope that this will work for you.

It assumes that you have nothing to the right of the results and that your data is on Sheet1.

Put this into a standard code module.

Test it on a copy of your data.

If you have not got a row set up for a P number or a column set up for a Stage Gate number it will warn you and then
abort the procedure.

VBA Code:
Public Sub subTranspose()
' https://www.mrexcel.com/board/threads/how-to-transpose-results-horizontally.1234004/#post-6042705
Dim rngData As Range
Dim arr() As Variant
Dim i As Integer
Dim intRow As Integer
Dim strP As String
Dim rngFound As Range
Dim rngRow As Range
Dim rngColumn As Range
Dim Ws As Worksheet

On Error GoTo Err_Handler

    ActiveWorkbook.Save

    Set Ws = Worksheets("Sheet1")
   
    Set rngData = Ws.Range("A3:C" & Range("A1").End(xlDown).Row)
       
    arr = rngData
   
    Ws.Activate
   
    Ws.Range("F4:AZ10000").Value = ""
   
    intRow = 4
   
    For i = LBound(arr) To UBound(arr)
   
        If Left(arr(i, 1), 1) = "P" Then
            strP = arr(i, 1)
            Set rngRow = Ws.Range("E4:E500").Find(strP, LookIn:=xlValues)
            If rngRow Is Nothing Then
                MsgBox "Cannot find a row for " & strP, vbCritical, "Warning!"
            End If
            intRow = intRow + 1
        Else
            Set rngColumn = Ws.Range("E3").Resize(1, 50).Find(arr(i, 1), LookIn:=xlValues)
            If rngColumn Is Nothing Then
                MsgBox "Cannot find a column for " & arr(i, 1), vbCritical, "Warning!" & " " & Ws.Range("E3").Resize(1, 50).Address
            End If
            Ws.Cells(intRow, rngColumn.Column).Resize(1, 2).Value = Array(arr(i, 2), arr(i, 3))
        End If
       
    Next i
   
    MsgBox "The data has been transposed.", vbInformation, "Confirmation"
   
Exit_Handler:
   
    Exit Sub
   
Err_Handler:
   
   MsgBox Err.Number & " " & Err.Description
  
   Resume Exit_Handler
   
End Sub
Hi. It did not work. I got error "91 Object variable or With block variable not set".
I have inserted Activity id in column d such as "Project1" "Project2" etc
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top