Consulting

Results 1 to 6 of 6

Thread: Remove Multiple Header Rows

  1. #1
    VBAX Regular
    Joined
    Feb 2011
    Posts
    34
    Location

    Remove Multiple Header Rows

    Hi,
    I Import multiple XML file, format of file is same, On every import it creates a header row for table, I need a macro which deletes the table header row and creates a single table and header.

    Table 1 :

    | Person | Week Of | Task | Hours|
    | Bob | 1/6/13 | Foo | 12 |
    | Mary | 1/6/13 | Foo | 7 |
    | Mary | 1/6/13 | Bar | 5 |
    | John | 1/6/13 | Foo | 5 |
    | John | 1/13/13 | Foo | 13 |
    Table 2 :
    | Person | Week Of | Task | Hours |
    | Bob | 1/6/13 | Baz | 3 |
    | Mary | 1/6/13 | Baz | 2 |
    | John | 1/13/13 | Baz | 5 |
    Result:
    | Person | Week Of | Task | Hours |
    | Bob | 1/6/13 | Foo | 12 |
    | Mary | 1/6/13 | Foo | 7 |
    | Mary | 1/6/13 | Bar | 5 |
    | John | 1/6/13 | Foo | 5 |
    | John | 1/13/13 | Foo | 13 |
    | Bob | 1/6/13 | Baz | 3 |
    | Mary | 1/6/13 | Baz | 2 |
    | John | 1/13/13 | Baz | 5 |

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    "Please" ?

    "Thank You" ?

    Other than that, can you attach sample of the XML file? Please

    After you import the XML file into a worksheet, does column A contain the word 'Table'?

    Paul

  3. #3
    VBAX Regular
    Joined
    Feb 2011
    Posts
    34
    Location
    Quote Originally Posted by Paul_Hossler View Post
    After you import the XML file into a worksheet, does column A contain the word 'Table'?
    Paul

    No, Col A does not have word 'Table'.

    Sample file uploaded.
    Attached Files Attached Files

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Well the sample file does not match the fields in the first post

    | Person | Week Of | Task | Hours|


    It has
    id author title genre price publish_date


    so you'll probably have to modify the example below:


    Option Explicit
    Sub DeleteRows()
        
        Dim loTable As ListObject
        Dim iRow As Long
        
        Application.ScreenUpdating = False
        
        With Worksheets("XML")
            
            For Each loTable In .ListObjects
                loTable.Unlist
            Next
            
            
            For iRow = .Cells(1, 1).CurrentRegion.Rows.Count To 2 Step -1
                If .Cells(iRow, 1).Value = "id" Then .Rows(iRow).Delete
            Next iRow
        End With
        Application.ScreenUpdating = True
    
    End Sub
    Paul

  5. #5
    VBAX Regular
    Joined
    Feb 2011
    Posts
    34
    Location
    Hi,

    Paul thankyou for your help.

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    You're welcome

    Glad to help

    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •