View Full Version : How to get value from a specific cell in Excel
pyang
08-05-2004, 01:38 AM
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
kevina
08-05-2004, 09:03 AM
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.
pyang
08-05-2004, 09:05 PM
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
--------------------------------------------------------------------------------
pyang
08-09-2004, 10:33 PM
Anybody can help me???
kevina
08-10-2004, 09:24 AM
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
pyang
08-10-2004, 09:23 PM
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
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.