+ Reply to Thread
Results 1 to 8 of 8

Using VBA to determine where the "Header Row" is located in file

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Using VBA to determine where the "Header Row" is located in file

    I have a macro where i open up several files and then process each one as i open it up.

    One thing that keeps changing is the location of the header row. As a result the macro stops / or results in erroneous results if i dont find the header row correctly.

    So i was thinking of defining the header row as follows:

    Header_row: Is the row with most entries and has the rt-most entry in a given row.

    I was thinking of using this last statment to help ID the header row. But i am not sure the best way to even approach this without creating a prgm that takes for ever to run.

    I am enclosing a file to help.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Using VBA to determine where the "Header Row" is located in file

    i found this code online. It finds the col which has rt-most data in it and returns the row for that which has the rt-most data in it.

    Please Login or Register  to view this content.
    i think this should work..........

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Using VBA to determine where the "Header Row" is located in file

    ok this does NOT work.

    Problem: Lets say that header row (row=1)and last data row in the table (row=32). SInce both have the same "last column". What i am finding is the row for the last data row not the header. Code is below..........i also include an excel file


    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Using VBA to determine where the "Header Row" is located in file

    ok.......this is what i came up with.........seems to work..........famous last words by me


    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Using VBA to determine where the "Header Row" is located in file

    did not paste all the right code

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Using VBA to determine where the "Header Row" is located in file

    ok, still not working 100%.

    anyone have any ideas let me know.

    If col has blanks in it obviously it does not work.

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Using VBA to determine where the "Header Row" is located in file

    posting a new file. use sheet 2............goal is to find the header row which is row 17..........

    any ideas how to do this?
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Using VBA to determine where the "Header Row" is located in file

    any one have anythoughts on how to identify the "header row" of a file.

    I define what that is in my first post of this thread.........i have also included files showing the header row.................

    anythoughts would be appreaciated

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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