Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Wes Wes is offline
external usenet poster
 
Posts: 26
Default Getvalue from closed workbook

I've been using a function "GetValue" which gets a value from a closed
workbook. (Found at: http://j-walk.com/ss/Excel/tips/tip82.htm) Works great
except I want to put this into a loop to reference different cells.
Therefore I'm trying to change it so that it accepts TheRow and TheColumn as
arguments instead of ref which is in A1 notation.

Private 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


Thanks in advance for your help.

  #2   Report Post  
Posted to microsoft.public.excel.misc
Wes Wes is offline
external usenet poster
 
Posts: 26
Default Getvalue from closed workbook

Sorry, wrong group, I'll post this in the Programming group.

"Wes" wrote:

I've been using a function "GetValue" which gets a value from a closed
workbook. (Found at: http://j-walk.com/ss/Excel/tips/tip82.htm) Works great
except I want to put this into a loop to reference different cells.
Therefore I'm trying to change it so that it accepts TheRow and TheColumn as
arguments instead of ref which is in A1 notation.

Private 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


Thanks in advance for your help.

Reply
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
Help - Does value exist in range of CLOSED workbook? c mateland Excel Worksheet Functions 9 April 16th 07 06:53 PM
Linking to a closed workbook Danedel Excel Worksheet Functions 2 February 3rd 06 06:43 PM
How to refenence ranges on a closed workbook GjArt Excel Discussion (Misc queries) 4 November 29th 05 03:49 PM
Value from a closed workbook Anthony Slater Excel Discussion (Misc queries) 5 May 17th 05 09:49 AM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM


All times are GMT +1. The time now is 07:13 AM.

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

About Us

"It's about Microsoft Excel"