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: 149
Default Application.Evaluate (works with SIN but not RGB)

All,

Direct Question: Is it possible to get the Long result of RGB from a string
expression (reference Evalute) using built-in VBA functionality?

The code below (comments included) illustrates that the SIN function works
properly with Evaluate, but the RGB function does not. (See VBE help for
more details on the Evaluate method). I believe that RGB does not work
because, as far as I can tell, RGB is a VBA function and not a worksheet
function. (Also, as far as I can tell, SIN is both a VBA and worksheet
function).

So, is it possible to get the Long result of RGB from a string expression
using built-in VBA functionality? (If I need to build a custom function to
do this for me, then that is not a problem because I can write the syntax,
and because I'm sure there is code out there for converting the RGB integer
values to a Long. I simply want to see if there is built-in functionality
that would prevent me from having to create a custom function to achieve the
same result).

Thanks,

Matthew Herbert

Sub EvaluateStringQuestion()
Dim strSin As String
Dim dblSin As Double
Dim strRgb As String
Dim lngRGB As Long
Dim varRgb As Variant

'----------------------------------------------------------
'SIN Related (Shown to prove Evaluate does work)
strSin = "SIN(45)"

'The following is 0.850903524534118:
dblSin = Application.Evaluate(strSin)
'----------------------------------------------------------

'----------------------------------------------------------
'RGB Related (Doesn't seem to work)
strRgb = "RGB(242, 242, 242)"

'The following is 15921906 (which is what I expect
' from varRgb):
lngRGB = RGB(242, 242, 242)

'The following returns "Error 2029", hence the Variant
' data type:
varRgb = Application.Evaluate(strRgb)

'The following do not work:
' lngRGB = Application.Evaluate(strRgb)
' lngRGB = Application.Evaluate("RGB(242, 242, 242)")
'----------------------------------------------------------

End Sub
 
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
Application.Evaluate Carim[_2_] Excel Programming 13 January 7th 09 08:50 PM
Application.Evaluate question lcsma Excel Programming 2 December 12th 08 01:21 PM
evaluate function only in Excel application x taol Excel Programming 1 March 17th 08 09:53 PM
Interpretation of Application.Caller.Parent.Evaluate FARAZ QURESHI Excel Discussion (Misc queries) 1 December 29th 07 07:59 PM
Error 2015 with Application.Evaluate Jeff Excel Programming 3 June 6th 06 04:00 PM


All times are GMT +1. The time now is 12:30 PM.

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"