How do I lookup a cell value (given row number and column number) and return it?

kwokv616

Registered User.
Local time
Yesterday, 23:36
Joined
Nov 10, 2008
Messages
46
How do I lookup a cell value (given row number and column number) and return it to a variable?

This is what I want to do:

temp = table(row_number,column_number)

I've searched through the internet and tried various methods and still cannot do it =(

Please Help!!
Many thanks!!
 
Are you talking about Access, or Excel?

If you are referring to an Access table, please give up, once and for all time, the idea that Access tables are anything like Excel worksheets. They are different objects, created for different purposes.

If you can tell us what exactly it is that you are actually attempting to accomplish, we may be able to put you on the right track.
 
Basically, I've got an Excel spreadsheet with columns A-CX (with headings 'age' 'year0' to 'year100') and rows 1-72 (titles 'age' '0' to '70'), and I need to look up a value (a cell) from it and use it in Access.

I have defined variables "iage" and "dur" (both integers) and I need to read the value in the cell [row(iage+1) and column (dur+2)] (somehow like an array) that's why i can't look it up from Excel directly since I'm not using column names and row numbers.

i need to use iage and dur because they are input values from other users which is making it so diffcult...
 
First you need to create a new instance of excel, open the workbook and specify the worksheet. Then you can return the value in the cell.

Code:
dim xlApp = excel.application
dim wb = excel.workbook
dim ws = excel.worksheet

dim path as string 'this is the location of the file that contains the data you want to lookup

path = "c:\somewhere\name.xls"

set xlApp = new excel.application

set wb = xlApp.workbooks.open(path)

set ws = wb.worksheets("SheetName")

temp = ws.cells(iage + 1, dur + 2).value

Temp will now hold the value you want
 

Users who are viewing this thread

Back
Top Bottom