LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Code that retrieves values from a closed workbook

Hey guys

I believe I picked up this function in this newgroup. I
really cant remember. Anyway what it does is it pulls
data using code (not formula links) from a closed
workbook. Is there anyway that if I new a value in a
closed workbook, that I could search for that in the
closed workbook, and then return the cell address where
the value is located once it found that value? For
example lets say I know the value "Dog" is in Closed
workbook "C:\Test.xls" It is in cell C2. I would want to
run the code from whatever workbook I am in. When I run
it, it returns the value C2. It returns the value C2
because the value "Dog" is located in that cell. Is this
sort of thing possible?

Function GetValue(path, file, sheet, ref)
' Retrieves a value from a closed workbook
Dim arg As String

' Make sure the file exists
If Right(path, 1) < "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File Not Found"
Exit Function
End If

' Create the argument
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)

' Execute an XLM macro
GetValue = ExecuteExcel4Macro(arg)
End Function


Thank you
Todd Huttenstine
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading values from a closed workbook Graham F New Users to Excel 6 July 28th 08 03:32 PM
Help...Code to copy sheet from closed workbook [email protected] Excel Discussion (Misc queries) 1 March 28th 07 08:52 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
Code for Opening a Closed Workbook scrabtree23[_2_] Excel Programming 3 November 11th 03 03:48 PM


All times are GMT +1. The time now is 09:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"