+ Reply to Thread
Results 1 to 11 of 11

Query and sort returning unwanted blank rows

  1. #1
    Registered User
    Join Date
    12-03-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Query and sort returning unwanted blank rows

    Hi - I am trying to run a very simply query that graps three columns of data from one worksheet and posts it to another in the same Workbook. This works fine. I then try to add a sort into the query so that the data is sorted by the third column. This works - but the returned data has several unwanted rowes of blank data in it.

    Can anyone solve this one for me?

    The third column in the original data happens to be a Vlooklup formula on a third workshee in the same workbook. I thought this might be significantr, so tried it with values in the cells rather than formulas - but the same result.....

  2. #2
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Query and sort returning unwanted blank rows

    Can you post a sample, this may help people to better understand your issue
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

  3. #3
    Registered User
    Join Date
    12-03-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Query and sort returning unwanted blank rows

    Hi Blake7, thanks for the prompt reply, just to say that I am running out the door now, will post this later, in hope that you are still following the thread...

    Actually, here it is...It's very rough, not to say a bit of a mess

    The query in question is on the first worksheet and sources data on the second which in turn has Vlookup formulae referring to the third.

    The query has returned the result correctly but has entered several blank unwanted rows...?
    Last edited by MattCole; 12-03-2010 at 10:16 AM. Reason: Have now uploaded file

  4. #4
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Query and sort returning unwanted blank rows

    Estimado Snr Cole,

    You need to be less ambiguous and speak more in terms of On sheet "TopLineQueries" "Cell A1" ect and not this column from there as it makes your post harder to follow.....

    Quote
    I am trying to run a very simply query what do you mean by query or do you mean a vlookup formula or simply =cellwhatever? that graps three columns of data from one worksheet which cols from which worksheet? and posts it to another in the same Workbook which sheet?. This works fine. I then try to add a sort sort what, where? into the query so that the data is sorted by the third column. This works - but the returned data has several unwanted rowes of blank data in it. Quote

    Quote
    The third column in the original again, give specifics data happens to be a Vlooklup formula on a third workshee in the same workbook. I thought this might be significantr, so tried it with values in the cells rather than formulas - but the same result.Quote

    The query in question is on the first worksheet are you talking about "topline queries" sheet? if so, I can't see any formula there.

    Why dont we start again, try and be specific, and post the sample demonstrating what you want to go where, ie desired output.....

    sorry to be a stick in the mud but without specifics i am having to de-crypt your highly codified requirement!!

  5. #5
    Registered User
    Join Date
    12-03-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Query and sort returning unwanted blank rows

    Really sorry about that, thanks for sticking with this, will post again as soon as I can to explain more, that may be tomorrow...

  6. #6
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Query and sort returning unwanted blank rows

    cool, have a good weekend

  7. #7
    Registered User
    Join Date
    12-03-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Query and sort returning unwanted blank rows

    Blake7, I really hope you're still checking this! So sorry to be so slow.

    OK - so, to clarify.

    Worksheet 'Topline Queries' contains a query - and only a query - that seeks to return data that is on the next Worksheet 'ToplineReport3PLUK' to be precise, Columns G - I.The Query not only imports the data from these columns but also runs a 'sort in ascending order' of column I.

    It manages to do both of these things (ie grab the data from the stated range) AND sort the relevant column accordingly, but when it does finally return this data to the 'Topline Queries' Worksheet, it inserts 22 blank unwanted rows before giving me the data ('Topline Queries Worksheet, Rows 2 -23).

    This is the problem.

    I think from memory that if I set up the quwery without the sort this would not happen, perhaps giving a clue as to the source of the problem, though to be honest I could not swear that I did try this since it has been a few days and I am inundated with work (not your problem I know!)

    The Vlookup mention in the oroginal post may have been a red herring - but I will explain it here. The data in Worksheet 'ToplineReport3PLUK' Column I - ie the column for the sort - (and some in Column H) - comes as a result of a Vlookup formula that seeks data from a third Worksheet - 'Detailed Data', Column K. I was wondering aloud whether this might not be the source of the problem in some way....?

  8. #8
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Query and sort returning unwanted blank rows

    Hi Matt, sorry, ive got alot on at the mo.

    In the workbook you posted I cannot see how you got the data from sheet "TOPLINEREPORT3PLUK"

    into sheet "TOPLINE QUERIES" as they are values only. As such I cannot comment why you are getting the 22 rows of blank data.

    In Sheet "TOPLINE QUERIES"

    Cell A2

    =INDEX(TOPLINEREPORT3PLUK!G6:G6,COUNTA(TOPLINEREPORT3PLUK!G6:G6))

    Drag accross and down as far as you want.

    With this you can type into sheet "TOPLINEREPORT3PLUK" Cols G, H and I and Sheet "TOPLINE QUERIES" will reflect what is typed - although re sorting in acsending order i think you will have to do that manually unless s'one offeres a VBA solution.

    Hope this helps.

  9. #9
    Registered User
    Join Date
    12-03-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Query and sort returning unwanted blank rows

    Hi Blake, many many thanks for that.

    If you still have the energy for this, I can clarify something that I hope will help show you what I am trying to say. Apologies for not being clear. I am no techie.

    "In the workbook you posted I cannot see how you got the data from sheet "TOPLINEREPORT3PLUK"
    into sheet "TOPLINE QUERIES" as they are values only. As such I cannot comment why you are getting the 22 rows of blank data."


    These values got there by what I am (wrongly?) calling a query - using SQL?

    I have just learnt how to copy the code for what I asked it to do

    SELECT `TOPLINEREPORT3PLUK$`.`AVAILABLE 12 PACKS NON PENDING`, `TOPLINEREPORT3PLUK$`.NO2, `TOPLINEREPORT3PLUK$`.`STRIPPED BOTTLES`
    FROM `TOPLINEREPORT3PLUK$` `TOPLINEREPORT3PLUK$`
    ORDER BY `TOPLINEREPORT3PLUK$`.`STRIPPED BOTTLES`

    This is how I get the data there. And this is returning it - complete with sort - but with 22 rows of blank rows.

    I can confirm that if I re-write it without the sort command it returns it with no blank rows to the cell I'd expect.

    Is there a way to tell the SQL to carry on with the sort but not to insert the blank rows do you know??

    Thanks, Matt

  10. #10
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Query and sort returning unwanted blank rows

    Matt - oh dear oh dear!! lol..... I now understand your issue, but this is in fact an Excel Forum and not an SQL forum!

    The spreadsheet you posted is an "export" from an SQL query run against a database! as such I have no idea why there are 22 rows of blank data as its NOT an Excel issue!!

    btw

    the sql query should be s'thing like

    select
    From
    where
    order by Col name asc, Col name asc
    Last edited by Blake 7; 12-08-2010 at 10:33 AM.

  11. #11
    Registered User
    Join Date
    12-03-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Query and sort returning unwanted blank rows

    Aha! You learn something new every day. Or in my case - when it comes to messing with digital data - 100 new things. Thanks a lot for your time, apologies again, will re-post on an apt forum armed with new knowledge! Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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