#1
|
|||
|
|||
How to get value from a specific cell in Excel
Hi,
I would like to retrieve the value from a particular cell location in an Excel doc and put it in a macro. How can i do that? Pls advice. Thank you. py |
#2
|
|||
|
|||
You can use script code to do this using the Excel COM interface. Search the internet for an example, they are plentiful. There are probably free components that you can leverage to assist in this as well.
|
#3
|
|||
|
|||
I'm not very sure. About the COM interface.
I've tried the following it is not showing any value? Pls advice. Thank you. -------------------------------------------------------------------------------- Dim xlApp Dim xlBook Dim xlSheet ' set reference to Application object Set xlApp = CreateObject("Excel.Application") ' set reference to Workbook object Set xlBook = xlApp.Workbooks.Open("C:\test.xls") ' set the reference to Worksheet for Common Set xlSheet = xlBook.WorkSheets(1) xlSheet.Range(%SRC_ROW%:%SRC_COL%).Value = %SOURCE_LOC% msgbox(%SOURCE_LOC%), VBOK, "Test" ' close Excel and destroy object variables xlApp.Quit Set xlSheet = Nothing Set xlBook = Nothing Set xlApp = Nothing -------------------------------------------------------------------------------- |
#4
|
|||
|
|||
Anybody can help me???
|
#5
|
|||
|
|||
Dim xlApp
Dim xlBook Dim xlSheet Dim Value ' set reference to Application object Set xlApp = CreateObject("Excel.Application") ' set reference to Workbook object Set xlBook = xlApp.Workbooks.Open("C:\test.xls") ' set the reference to Worksheet for Common Set xlSheet = xlBook.WorkSheets(1) 'Value = xlSheet.Range(vbld_AllMacros()("SRC_ROW").Value & ":" & vbld_AllMacros()("SRC_COL")).Value Value = xlSheet.Range("1:1").Text Application.Macros(vbldTemporary).Add "SOURCE_LOC", Value msgbox vbld_AllMacros()("SOURCE_LOC").Value, VBOK, "Test" ' close Excel and destroy object variables xlApp.Quit Set xlSheet = Nothing Set xlBook = Nothing Set xlApp = Nothing |
#6
|
|||
|
|||
Hi kevina,
Thank you. But it is still not showing any value in the messagebox neither is the macro SOURCE_LOC!!! Any idea? Thank you. py |
|
|