adodb query excel spreadsheet, query return sheet row?


Well-known Member
May 27, 2010
Experimenting with queries to my worksheet. So far, I can successfully get meaningful results back, but wonder how I can get those results to include the row they were found in??

My query Looks something like "SELECT [test1], [test2] FROM [Sheet1$]"
Want query to get row some how in results "SELECT ROW() as MyRow, [test1], [test2] FROM [Sheet1$]"

Obviously ROW() in my query doesn't work. I dont really want to add a row() formula to a cell in a column either; just thought there should be a way to return the row as a value in my adodb recordset. Any idea's?


Well-known Member
May 27, 2010
The reason why I'd like to have the row number return in the recordset as a value, is because I need to format the specific row, in Sheet1, in excel, afterwards; by format I mean change the color and other fancy stuff that you'd never accomplish via adodb.

oh!! and the above queries will be more something like "SELECT [test1], [test2] FROM [Sheet1$] WHERE [test1] = "MrExcel"
The query will be applied against a sheed named Sheet1 with named ranges test1, test2. The sheet has about 5000 rows of data. My Query will likley return 2-3 rows and need to know the rows as a value in my query, as mentioned earlier.
Last edited:

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...