+ Reply to Thread
Results 1 to 5 of 5

Excel Query in VBA without Column Headers

Hybrid View

  1. #1
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Excel Query in VBA without Column Headers

    Hi, Not sure if this is in the right place but.......

    I just wondered if its possible that when you run a query via VBA you can omit the columns headers and return the query into the specified cell.

    Any help would be appreciated

    Many Thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Excel Query in VBA without Column Headers

    Hi,

    Just checked one of mine and the syntax is the .TextFileStartRow
    i.e.

    
    With Sheets("mysheet").QueryTables.Add(Connection:="myconnection;" & "myfile", _
    & Destination:=Sheets("Mysheet").Range("myrange").Cells(1, 1))
          .TextFileStartRow = 2
    'etc..
    
    End WIth
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Re: Excel Query in VBA without Column Headers

    Thanks for that but it doesn't seem to work. I'm actually pulling the data from a DBF file if that makes any difference

    Thanks again

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Excel Query in VBA without Column Headers

    Might be worth while googling to see if there's an equivalent of the .TextFilesStartRow syntax.

    You could always add a line of code

    Range("myimportdata").cells(1,1).EntireRow.Delete

  5. #5
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Re: Excel Query in VBA without Column Headers

    I've found that

    .FieldNames = False
    sorts the problem

    Thanks

+ 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