vba to transpose rows headers and data to columns headers with respective data

  • Trying to move data in contigious way .


    Columns A shows Headers at row 8 and 9.


    At row 38 shows page no .


    When the going to next page no there is a difference of 6 and the pattern remains same between page nos.


    How to move the actual data of column A in vba to a new sheet (test)in same workbook by transposing the headers to row 1 as well as data with it page numbers.


    The data can reach 100 pages as shown in column A

  • Re: vba to transpose rows headers and data to columns headers with respective data


    Hello! Give this a try:

  • Re: vba to transpose rows headers and data to columns headers with respective data


    An alternative approach.


    Click the button on sheet on attached file.


    Code assigned to the button

  • Re: vba to transpose rows headers and data to columns headers with respective data


    You're welcome.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: vba to transpose rows headers and data to columns headers with respective data


    Hello KjBox


    Trying your code on bigger no of pages getting issues


    runtime error 9 script out of range


    the word below represents end of report




    [TABLE="width: 108"]

    [tr]


    [TD="class: xl63, width: 144"]Item Total:[/TD]

    [/tr]


    [/TABLE]



    the pages can reach 200 to 300 pages .


    Test on 8 pages was unsuccesful


    Could you look in

    Code
    y(1, iii) = CInt(Split(x(UBound(x), 1))(2))
  • Re: vba to transpose rows headers and data to columns headers with respective data


    That error was due to an inconsistency in your data, for the first 3 pages each section ended with "Page Number: 1" but from page 4 onwards there is no space after the colon ("Page Number:4").


    I have modified the code to account for that, also included a Function to transpose the array before placing its contents onto the new sheet because Application.Transpose may fail when your data is mre than 100 pages.


    Change the code to this:

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: vba to transpose rows headers and data to columns headers with respective data


    Apologize for this trouble, the code works well , but need a little tuning when there is 0 in front of numbers ,


    applying code removes the 0 as below example,


    Could you adjust


    thanks











Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!