Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check a value in Excel

Status
Not open for further replies.

Zygor

Technical User
Apr 18, 2001
271
US
Is there a way to check the value of a cell in a closed workbook, before I import it into Access?
 
Yes, off the top of my head there are two options:

You can open the workbook using OLE and check the cell.
- or -
You can query the workbook using ADO to check the cell.

Do you have a technology preference?

CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Thanks for the response. Here's what I came up with

Private Function ValidateVersion(strFileToCheck As String) As Boolean
Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet

Set objXL = New Excel.Application

Set objWkb = objXL.Workbooks.Open(strFileToCheck)

Set objSht = objWkb.Worksheets("tblResults")

If InStr(1, objSht.Cells(2, 28).Value, "2.5") Then
ValidateVersion = True
Else
ValidateVersion = False
End If

DoEvents

objXL.Quit

Set objSht = Nothing
Set objWkb = Nothing
Set objSht = Nothing

End Function
 
That pretty much matches my picture of option 1, does it do what you need it to do or are you still having a problems?

CMP

(GMT-07:00) Mountain Time (US & Canada)
 
It worked like I hoped. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top