Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VBA: "Volatile" use of concatenated worksheetfunction expression

Help urgently needed for this:

Sub x()
Dim a As String
Dim b As Variant
ReDim b(1 To 2, 1 To 1)
b(1, 1) = 1
b(2, 1) = 2
a = "Sum"

'This Works fine: "3"
MsgBox WorksheetFunction.Sum(b)

'This does not work: "WorksheetFunction.Sum(b)"
'I need to "force" an evaluation of the expression "WorksheetFunction.Sum(b)"
MsgBox "WorksheetFunction." & a & "(b)"
End Sub

Thanks a lot in advance !
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBA: "Volatile" use of concatenated worksheetfunction expression

CallByName can only be used with vba6 = NOT in xl97

Sub x()
Dim a As String
Dim b As Variant
ReDim b(1 To 2, 1 To 1)
b(1, 1) = 1
b(2, 1) = 2
a = "SUM"

MsgBox CallByName(Application, a, VbGet, b)

End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"?B?RmFjdGl2YXRvcg==?="
wrote:

Help urgently needed for this:

Sub x()
Dim a As String
Dim b As Variant
ReDim b(1 To 2, 1 To 1)
b(1, 1) = 1
b(2, 1) = 2
a = "Sum"

'This Works fine: "3"
MsgBox WorksheetFunction.Sum(b)

'This does not work: "WorksheetFunction.Sum(b)"
'I need to "force" an evaluation of the expression
"WorksheetFunction.Sum(b)" MsgBox "WorksheetFunction." & a & "(b)"
End Sub

Thanks a lot in advance !


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default VBA: "Volatile" use of concatenated worksheetfunction expression

You can use Evaluate:
Public Function EVAL(theInput As Variant) As Variant
'
' if UDF evaluate the input string as though it was on this sheet
' else evaluate for activesheet
'
Dim vEval As Variant
Application.Volatile
On Error GoTo funcfail
If not IsEmpty(theInput) then
If TypeOf Application.Caller.Parent Is Worksheet Then
vEval = Application.Caller.Parent.Evaluate(Cstr(theInput))
Else
vEval = Application.Evaluate(cstr(theInput))
End If
If IsError(vEval) Then
EVAL = CVErr(xlErrValue)
Else
EVAL = vEval
End If
End If
Exit Function
funcfail:
EVAL = CVErr(xlErrNA)
End Function

regards

Charles
______________________
Decision Models
The Excel Calculation Site.
www.DecisionModels.com



"keepITcool" wrote in message
...
CallByName can only be used with vba6 = NOT in xl97

Sub x()
Dim a As String
Dim b As Variant
ReDim b(1 To 2, 1 To 1)
b(1, 1) = 1
b(2, 1) = 2
a = "SUM"

MsgBox CallByName(Application, a, VbGet, b)

End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"?B?RmFjdGl2YXRvcg==?="
wrote:

Help urgently needed for this:

Sub x()
Dim a As String
Dim b As Variant
ReDim b(1 To 2, 1 To 1)
b(1, 1) = 1
b(2, 1) = 2
a = "Sum"

'This Works fine: "3"
MsgBox WorksheetFunction.Sum(b)

'This does not work: "WorksheetFunction.Sum(b)"
'I need to "force" an evaluation of the expression
"WorksheetFunction.Sum(b)" MsgBox "WorksheetFunction." & a & "(b)"
End Sub

Thanks a lot in advance !




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
whyis "paste spl" copying concatenated cell changing lastdigit2 0 robin Excel Worksheet Functions 1 December 5th 06 05:49 PM
CELL("filename") acting Volatile? (in assoc. with PULL) [email protected] Excel Worksheet Functions 4 August 3rd 06 03:23 PM
How can I get "=TODAY()" results to be non-volatile? FBC Dave Excel Worksheet Functions 2 August 2nd 06 06:21 PM
=CELL("filename") VOLATILE? DR Hall Excel Worksheet Functions 6 December 31st 05 06:32 PM
Excel expression "sumproduct" in Access fatfish Excel Programming 0 June 24th 04 03:17 PM


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