+ Reply to Thread
Results 1 to 5 of 5

Transpose web data from horizontal (rows) to vertical (columns)

  1. #1
    Forum Contributor
    Join Date
    06-18-2012
    Location
    Kuching, SARAWAK
    MS-Off Ver
    Excel 2010
    Posts
    116

    Transpose web data from horizontal (rows) to vertical (columns)

    Hye Excel Expert,

    Attached is the sample of web data for transpose process. Generally, each portion is a group of data consists of the following parameters:-

    Work Order ID
    Submit Date
    Submitter
    Communication Source
    View Access
    Notes

    The source data (web data) is in horizontal mode and every portion is separated by a line. If we see the pattern for the value for each parameter, each parameter only has 1 row value, EXCEPT parameter 'Notes' that may vary from 1 portion to another. However, I need the output to be as the following (with sample data):-

    Work Order ID Submit Date Submitter Communication Source View Access Notes
    WO0000000075830 *04/01/2018 7:47:35 PM *v04784x * Public * User ID have been created.refer attachment.TQ.

    I have hundreds of web data files in a folder in local PC. I need a macro that can loop all web data files in the folder, transpose each portion from horizontal (rows) to vertical (columns) manner with the parameter names as the header which needs only to be published once in one master worksheet. I manage to find one macro that can transpose but the macro only limits to a fixed number of columns, which will not be applicable when the number of rows as values in parameter 'Notes' is consists of multiple rows (inconsistent number of rows).

    Below is the macro I found that I think very close-relation to my problem.

    Please Login or Register  to view this content.


    Can anyone help me, please?

    Tqvm in advance.
    DZ
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Dahlia; 08-10-2018 at 05:26 AM. Reason: attach file

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Post

    Cleared a duplicate …
    Last edited by Marc L; 08-10-2018 at 08:43 AM.

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this ‼


    First create a brand new workbook with one worksheet, create headers in row #1,
    paste the below demonstration to the worksheet module Sheet1
    then save the workbook in the parent folder of the web files folder
    (in fact whatever as you can mod the path within the code) …

    As a beginner starter to transpose from vertical to horizontal :

    PHP Code: 
    Sub Demo1()
              
    Dim L&, P$, F$, Rg As RangeR&
              
    Me.UsedRange.Offset(1).Clear
              Application
    .ScreenUpdating False
              L 
    1
              P 
    ThisWorkbook.Path "\Sample Source Data\"
              F = Dir(P & "
    *.htm")
        While F > ""
            With Workbooks.Open(P & F).Worksheets(1).UsedRange.Columns(1)
                   Set Rg = .Find("
    Work Order ID", , xlValues, xlWhole)
                If Not Rg Is Nothing Then
                        R = Rg.Row
                    Do
                        With Rg.CurrentRegion.Rows
                           V = Application.Index(.Columns(2), [COLUMN(A:F)])
                           If .Count > 6 Then V(6) = Join(Application.Index(.Item("
    6:" & .Count).Columns(2), _
                                      Evaluate("
    COLUMN(" & [A1].Resize(, .Count - 5).Address & ")")), vbLf)
                        End With
                           L = L + 1
                           Cells(L, 1).Resize(, 6).Value = V
                           Set Rg = .FindNext(Rg)
                    Loop While Rg.Row > R
                End If
                   .Parent.Parent.Close False
            End With
              F = Dir
        Wend
              Set Rg = Nothing
              Application.ScreenUpdating = True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 08-10-2018 at 09:09 AM. Reason: new version, easier at beginner level …

  4. #4
    Forum Contributor
    Join Date
    06-18-2012
    Location
    Kuching, SARAWAK
    MS-Off Ver
    Excel 2010
    Posts
    116

    Re: Hi ! Try this ‼

    Thank you so much for the awesome solution, Marc L !

    Your code works like a charm! 100% like how I wanted to be!!

    Best ever!

    Sincerely,
    DZ

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Transpose web data from horizontal (rows) to vertical (columns)


    Thanks for the rep '!

    I just mixed VBA basics as any beginner can (must !) read in VBA inner help (see the Find method sample)
    with Excel worsheet formula (INDEX & COLUMN) to transpose the data …

+ 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. Transpose vertical data to horizontal
    By PeterKeown in forum Excel General
    Replies: 6
    Last Post: 08-03-2018, 05:51 AM
  2. Transpose huge data from horizontal to vertical
    By AaruJaan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2017, 12:13 PM
  3. Replies: 3
    Last Post: 04-27-2015, 05:26 PM
  4. Replies: 4
    Last Post: 08-22-2013, 11:56 AM
  5. [SOLVED] Converting Vertical Columns in to Horizontal Rows - (Better solution to Transpose)
    By ps_upasani in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-30-2013, 05:32 AM
  6. Transpose Vertical Data to Horizontal
    By Randu555 in forum Excel General
    Replies: 5
    Last Post: 04-18-2013, 05:05 PM
  7. Replies: 2
    Last Post: 06-06-2012, 07:13 PM

Tags for this Thread

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