Hi,

I need to be able to open an already filled in 2003 excel file (.xls) search a column for data and then return the row that matches the criteria.

The sheet has formatting at the top and bottom and is dynamic, it is updated regularly so number of row is an unknown when opening the file. Here is some of the code that I have found by RobDog888 and some others. So I can connect and get specific information from a specified cell but I am lost on how to baiscly perform an SQL statement against it. Any help will be welcomed.
VB Code:
  1. Option Explicit
  2.  
  3. 'Add a reference to ms excel xx.0 object library
  4.     Private Sub command1_click()
  5.     Dim oapp As Excel.Application
  6.     Dim oWB As Excel.Workbook
  7.     Set oapp = New Excel.Application
  8.     oapp.Visible = False
  9.     Set oWB = oapp.Workbooks.Open("M:\programming\VB6\reset\R50093.xls")
  10.     MsgBox oapp.Workbooks(1).Sheets("RS-04").Cells(7, 1) 'Cell A1
  11.    
  12.    
  13. Dim topCel As Range, bottomCel As Range
  14. Dim NoOfRows As Integer, a As Integer
  15.  
  16. 'Count entries
  17. With ActiveSheet
  18.     Set topCel = .Range("A7")
  19.     Set bottomCel = .Cells((65536), topCel.Column).End(xlUp)
  20.         If bottomCel.Row <= topCel.Row Then
  21.         Exit Sub
  22.         End If
  23. NoOfRows = .Range(topCel, bottomCel).Rows.Count
  24. MsgBox NoOfRows + 6
  25.  
  26. End With
  27.  
  28. oWB.Close
  29.     Set oWB = Nothing
  30.     oapp.Quit
  31.     Set oapp = Nothing
  32. End Sub