Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 174
Default ExecuteExcel4Macro

Hi All,

Using Excel 2003.


Code:


Option Explicit
Const ALT_PLANNING_PATH As String = "D:\Data\Watch\"
Const PLANNING_FILE As String = "ROC 2009.xls"

Sub test()
Dim result As Variant
result = GetValue(ALT_PLANNING_PATH, PLANNING_FILE, "Engineers", "A1")
Debug.Print result
End Sub
'''GetValue(ALT_PLANNING_PATH,PLANNING_FILE,"Engin eers", A1)

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''
''' Function: GetValue
'''
''' Comments: Looks up the value in the planning file
'''
'''
'''
''' Date Developer Action
''' -------------------------------------------------------------------------
''' dd/mm/yyyy John Walkenbach Created
'''
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)
If GetValue = 0 Then GetValue = ""
End Function

As I mentioned in the function comments, I have found the code on John's
page, honour to whom it belongs to.

Is there a way I could use this to get a range of cells instead of one
single cell?

With kind regards,

JP







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
Print using ExecuteExcel4Macro Fred Excel Programming 2 March 10th 09 09:40 PM
ExecuteExcel4Macro to run on other page Makelei Excel Programming 5 December 13th 08 07:50 PM
ExecuteExcel4Macro ... RFraley[_2_] Excel Programming 1 September 22nd 06 05:11 PM
Executeexcel4Macro?? (Dave, I need some help) Max Potters Excel Programming 3 August 18th 04 12:59 PM
ExecuteExcel4Macro: Help with this Shilps Excel Programming 0 May 21st 04 10:41 AM


All times are GMT +1. The time now is 11:42 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"