What is the quick way to transfer data from row to column

Sian1

Board Regular
Joined
Nov 9, 2009
Messages
90
Request ID101102104105116134135143147148149
R-042A04GC700000149
R-023A0DAB800000149
R-042A059Q100000143149
R-042A059Q100000
R-042A059Q100000
R-005A0HFX800001102105149
R-042A059Y400000104134149
R-042A059Y400000149
R-023A0BE0200000149
R-001A0Y3T700000134135
R-001A0Y3T700000116143147149
R-023A0BE0200000101
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
It is different code inside the query. Copy and paste that and try.

Hi
I swear it works in the workbook you sent back but it didn't work when i did it exact in the same link. I am trying to convert the last 5 worksheets

Box
 
Upvote 0
It wouldn't convert those 5 sheets correctly as your layout is different to your test sample.
I'll see if I get time to look at it tomorrow.
 
Upvote 0
is it possible to do it in VBA?
If you are still interested in that approach, you could try this with a copy of your workbook.

VBA Code:
Sub ReworkCodes()
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, k As Long, uba2 As Long
  
  With Range("Table1")
    a = .Value
    uba2 = UBound(a, 2)
    ReDim b(1 To UBound(a, 1) * uba2, 1 To 2)
    For i = 1 To UBound(a)
      For j = 2 To uba2
        If Len(a(i, j)) Then
          k = k + 1
          b(k, 1) = a(i, 1): b(k, 2) = a(i, j)
        End If
      Next j
    Next i
    With .Offset(, .Columns.Count + 2).Resize(, 2)
      .Rows(0).Value = Array("Request ID", "Rework Code")
      .Resize(k).Value = b
    End With
  End With
End Sub
 
Upvote 0
Hi Peter, just been alerted to your post. Just so you are aware the latest layout in the workbook is as per the below (obviously for more rows )...
Edited as didn't include column A on the previous paste :rolleyes:

NP Reject (1).xlsb
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS
1Request IDNPP Rejection Date - HistoryNPP Rejection Reason - HistoryNPP Rejection Comments - HistoryRequest Rejection Count101102104105106107109112114115116117118119120122124126127129130131132133134135136137138139140141142143144145146147148149
2R-042A04GC70000029-Dec-2017149 INCORRECT / MISSING INVOICE OR REQUIRED DOCUMENTS; 1                                       149
3R-023A0DAB80000008-Jan-2019149 INCORRECT / MISSING INVOICE OR REQUIRED DOCUMENTS; Please, correct the Legal entity on RI invoice to American International Group UK Limited (AIG UK).Make the RI invoice visible for the Partner. Upload it as premium bill/premium bill1                                       149
4R-042A059Q10000020-Sep-2018143 NETWORK PARTNER FORM INNACCURATE / NOT ATTACHED; 149 INCORRECT / MISSING INVOICE OR REQUIRED DOCUMENTS; 129 DISCREPANCY/MISSING FACULTATIVE DECLARATION PAGE; En el recibo y en el certificado todavía pone Excess. Hay una dirección de Mozambique en el NPPRF Error en el certificado1                   129             143     149
5R-042A059Q10000001-Oct-2018129 DISCREPANCY/MISSING FACULTATIVE DECLARATION PAGE; Por favor modificar el certificado – hay un error en la tabla de impuestos y también la dirección del Asegurado está en Mozambique1                   129                    
6R-042A059Q10000003-Oct-2018129 DISCREPANCY/MISSING FACULTATIVE DECLARATION PAGE; Por favor modificar el certificado – hay un error en la tabla de impuestos y también la dirección del Asegurado está en Mozambique1                   129                    
7R-005A0HFX80000130-Jan-2020149 INCORRECT / MISSING INVOICE OR REQUIRED DOCUMENTS; 105 DISCREPANCY WITH PREMIUM VALUES; 102 DISCREPANCY WITH POLICY INCEPTION/EXPIRATION DATES; Pls, amend effective date to Feb. 1st in both Omega and the RI invoice (due to backdating restrictions in Chile). Pls, add NP fee and amend NEP in Omega. Pls, amend Omega Ref. number in the RI invoice.1 102 105                                   149
8R-042A059Y40000028-Aug-2018149 INCORRECT / MISSING INVOICE OR REQUIRED DOCUMENTS; 134 DISCREPANCY WITH INSURER TAXES; 104 COVERAGES INDICATED NOT PROVIDED LOCALLY; Please remove the EL, a special company covers it for Uruguay; correct the insurer tax to USD 12.27; correct the net exportable to 478.63; provide RI1  104                     134              149
9R-042A059Y40000029-Aug-2018149 INCORRECT / MISSING INVOICE OR REQUIRED DOCUMENTS; Please amend the RI to reflect the correct local name insured, address and contact name1                                       149
10R-023A0BE020000022-Dec-2017149 INCORRECT / MISSING INVOICE OR REQUIRED DOCUMENTS; 1                                       149
11R-001A0Y3T70000011-Oct-2017134 DISCREPANCY WITH INSURER TAXES; 135 DISCREPANCY WITH INSURED TAXES; Premium to be clarified, policy already issued1                        134135              
12R-023A0BE020000026-Apr-2018101 DISCREPANCY WITH LOCAL INSURED DETAILS; 1101                                       
13R-001A0Y3T70000022-Jan-2018143 NETWORK PARTNER FORM INNACCURATE / NOT ATTACHED; 147 MISSING AUTO LIST OF VEHICLES; 149 INCORRECT / MISSING INVOICE OR REQUIRED DOCUMENTS; 129 DISCREPANCY/MISSING FACULTATIVE DECLARATION PAGE; 116 DISCREPANCY WITH ISSUING OFFICE OVERRIDE/FEES; 1. NP fee should be $1139,30 2. Net exp premium should be $9035 3. Please attach the SOV 4. Please amend accordingly the NPPRF, RI invoice and Fac cert Please resubmit1          116        129             143   147 149
NPP History
 
Last edited:
Upvote 0
Just so you are aware the latest layout in the workbook is ...
Thanks Mark. I'll wait to see if the OP is interested in this approach based on the original sample data. If so, perhaps they will also provide an appropriate sample results for that new layout if not able to amend the code themselves.
 
Upvote 0
I have added queries to 4 of the 5 tabs.

Please note that the points raised in the quote below are incorrect, the output in KL is correct. I have left the quote in so the posts afterwards still make sense.
KL tab I have issues with as you have 101 in the cells rather than the column header value. Both my queries and the code Peter posted use the data in the cells so we get 101 for all the results (what is in KL sheet is the result of Peter's code adjusted for the sheet layout).

Peter's code can probably be adjusted to return the header value in this circumstance but I don't know how to do it with a query (we might get a response from @lrobbo314 or @sandy666 saying there is a way, just have to wait and see).

Sample code from the Table1 query (they all change slightly as there are different columns/No of columns in each tab)
VBA Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Removed Columns" = Table.RemoveColumns(Source,{"NPP Reject Date", "NPP Reject Reason", "NPP Reject Comments", "Request Rejection Count"}),
    Unpivot = Table.UnpivotOtherColumns(#"Removed Columns", {"Request ID"}, "Attribute", "Value"),
    Remove = Table.RemoveColumns(Unpivot,{"Attribute"}),
    #"Filtered Rows" = Table.SelectRows(Remove, each ([Value] <> ""))
in
    #"Filtered Rows"

Link to workbook
 
Last edited:
Upvote 0
Mark, I'm lost at this point. What are we trying to do now? Are we just looking at sheet "KL"? What is the desired output?
 
Upvote 0
I understand your confusion, just looked again at the table and the result should be a whole series of 101's. I mistakenly assumed that it was like some of the tables in the earlier workbook which had a layout like...

1583006921279.png


It doesn't, so all good I hope.

I have put an edit in my previous post.
 
Upvote 0

Forum statistics

Threads
1,215,361
Messages
6,124,497
Members
449,166
Latest member
hokjock

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