Need info from just one cell in excel

T

Trever B

Is it possible to lookup just the contents of 1 cell (Need cell F:4) from an
excel file.

This is needed to get the correct import file.

Thanks in advance

Trev.
 
D

Douglas J Steele

See whether the example in http://www.mvps.org/access/modules/mdl0006.htm at
"The Access Web" helps. (F4 would be row 4, column 6, so you'd want
..Cells(4,6) rather than .Cells(1,1))

Rather than the line

objXL.Application.Workbooks.Add

you'll want

objXL.Application.Workbooks.Open SpreadsheetName

(where SpreadsheetName is the full path to the spreadsheet)
 
A

AccessARS

Hello Douglas..I realize that this was posted years ago but I am facing a
very similary issue in trying to retrieve the value from a particular sheet
and cell in an existing spreadhsheet which has 3 worksheets. As indicated in
your reponse I have used the refereced code and manipulated it for my
purposes as follows...

Dim objXL As Object
Dim strWhat As String
Dim strXls As String
Dim objActiveWkb As Object

strXls = "A:\Dashboard\dbUploads\db_Actions.xls"


objXL.Application.Workbooks.Open (strXls)
Set objActiveWkb = objXL.Application.ActiveWorkbook

With objActiveWkb
strWhat = .Worksheets(1).Cells(1, 1).Value

End With

objActiveWkb.Close savechanges:=False

objXL.Application.Quit

Set objActiveWkb = Nothing: Set objXL = Nothing
msgbox strWhat


....unforunately the value that I get for that range which I'm assuming
".worksheets(1)" is looking at the 1st sheet and thereafter row 1 and column
1, does not correspond with any of the 3 sheets row 1 col 1 values??? Its
actually a number that I can't seem to tie to any cell in my spreadsheet at
this point.

Your assistance would be greatly appreciated....Thank you
 
J

Jeanette Cunningham

Hi,
It could be something about the particular workbook you are getting the
values from.

Create a new test workbook, put values in the first cell and try the code to
retrieve the values.
If it works OK, then what is the problem with db_Actions.xls?
If it doesn't work, debug on the new text workbook until you get it working.

Jeanette Cunningham
 
A

AccessARS

....you are definitly on the right track...The cell in question is in an a SAP
genertated Excel template. Although it allows you to save and close in an
excel file for later use, for some reason it won't allow me to view the
content from that sheet even if I link the cell into a second new sheet
within the same workbook. I will have to find a way around it...Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top