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

I have the following user defined function:

Function mytest2(ByVal Exposure As String, ByVal i As Integer)

msgbox "Step1"

mytest2 = Application.ExecuteExcel4Macro("Hlookup(""" & Exposure & """,
'C:\Reference Tables\[ASCE 7-02.xls]TABLE 1609.6.2.1(4)'!R3C2:R13C4, """ & 3
+ i & """, False)")

msgbox "Step2"

End Function


If I were to assign variables to Exposre and i, and then step through the
lines of code I get the value 1.6 for mytest2 - which is correct. The problem
i'm having is when I inset the function into the excel spreadsheet I get the
#Value error. Does anyone know why this is occuring? Is there some kind of
problem using ExecuteExcel4Macro in a user defined function. Also, If I were
to step through the lines of code I get both message boxes "Step1" and
"Step2". When I insert the user defined function into the spreadsheet, I get
the message box "Step1" but it never reaches "Step2".

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default ExecuteExcel4Macro Problem

In XL4 the HLookup function has 3 arguments not four.
They a lookup_value, table_array, row_index_num.
Also, if row_index_num is less than 1 , HLookup returns #Value.

Jim Cone
San Francisco, USA


"deepunderground" wrote in
message ...
I have the following user defined function:

Function mytest2(ByVal Exposure As String, ByVal i As Integer)
msgbox "Step1"
mytest2 = Application.ExecuteExcel4Macro("Hlookup(""" & Exposure & """,
'C:\Reference Tables\[ASCE 7-02.xls]TABLE 1609.6.2.1(4)'!R3C2:R13C4, """ & 3
+ i & """, False)")
msgbox "Step2"
End Function

If I were to assign variables to Exposre and i, and then step through the
lines of code I get the value 1.6 for mytest2 - which is correct. The problem
i'm having is when I inset the function into the excel spreadsheet I get the
#Value error. Does anyone know why this is occuring? Is there some kind of
problem using ExecuteExcel4Macro in a user defined function. Also, If I were
to step through the lines of code I get both message boxes "Step1" and
"Step2". When I insert the user defined function into the spreadsheet, I get
the message box "Step1" but it never reaches "Step2".

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default ExecuteExcel4Macro Problem

It could well be that ExecuteExcel4Macro is forbidden in UDFs, like many
other functions are.
If there is any chance that a function tries to change something in a
worksheet, it will cause Excel to return #VALUE.
Even a simple FIND will do this, because there is an option to replace.

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"deepunderground" wrote in
message ...
I have the following user defined function:

Function mytest2(ByVal Exposure As String, ByVal i As Integer)

msgbox "Step1"

mytest2 = Application.ExecuteExcel4Macro("Hlookup(""" & Exposure & """,
'C:\Reference Tables\[ASCE 7-02.xls]TABLE 1609.6.2.1(4)'!R3C2:R13C4, """ &
3
+ i & """, False)")

msgbox "Step2"

End Function


If I were to assign variables to Exposre and i, and then step through the
lines of code I get the value 1.6 for mytest2 - which is correct. The
problem
i'm having is when I inset the function into the excel spreadsheet I get
the
#Value error. Does anyone know why this is occuring? Is there some kind of
problem using ExecuteExcel4Macro in a user defined function. Also, If I
were
to step through the lines of code I get both message boxes "Step1" and
"Step2". When I insert the user defined function into the spreadsheet, I
get
the message box "Step1" but it never reaches "Step2".



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
How to call Macro(using ExecuteExcel4Macro) for a particular workbook [email protected] Excel Programming 6 December 22nd 04 11:23 AM
Executeexcel4Macro?? (Dave, I need some help) Max Potters Excel Programming 3 August 18th 04 12:59 PM
assign result of ExecuteExcel4Macro to an array keepitcool Excel Programming 6 May 28th 04 03:02 PM
ExecuteExcel4Macro: Help with this Shilps Excel Programming 0 May 21st 04 10:41 AM
ExecuteExcel4Macro Page.Setup Runtime Error Geoff Martin Excel Programming 1 January 27th 04 01:44 PM


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