Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default Evaluate("1")

Greetings,

This is strange - I wrote a simple macro (stored in my personal macro
workbook) to generate a column of equally spaced numbers. It contained
the line

stepSize = CDec(Evaluate(InputBox("Enter step size")))

I did it this way since I wanted to be able to enter mathematical
expressions like 1/45 and not just numbers. It seemed to work fine for
a week or so. But then - when I tried to use it to modify a previously
written spreadsheet the above line threw a "Run-time error 438 -
Object doesn't support this property or method" error on the stepsize
1. Somewhat curiously, I found that when I typed ?Evaluate("1") in the
immediate window I got the error but ?Evaluate("3") returned 3 as
expected. I experminented with several old workbooks and found that
for all of the ones I wrote in Excel 2000 (or earlier) and some that I
wrote in Excel 2003 I get the error when I type ?Evaluate("n") for
some but not all small n. Curiously, sometimes "1" is ok but it balks
at "2" or "3". Any idea what is going on?

The workaround was easy:

stepSize = CDec(Evaluate("=" & InputBox("Enter step size")))

seems ok.

Is Evaluate supposed to work this way or is it a bug?

-John Coleman

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Evaluate("1")

I never would have thought to add Evaluate to the mix. What does it add?

Sub a()
Dim stepSize As Variant
On Error Resume Next
stepSize = CDec(InputBox("Enter step size"))
If IsEmpty(stepSize) Then ''No entry, Cancel, Non-number
MsgBox "No step"
Else
MsgBox "Step is " & stepSize
End If
End Sub


--
Jim
"John Coleman" wrote in message
oups.com...
| Greetings,
|
| This is strange - I wrote a simple macro (stored in my personal macro
| workbook) to generate a column of equally spaced numbers. It contained
| the line
|
| stepSize = CDec(Evaluate(InputBox("Enter step size")))
|
| I did it this way since I wanted to be able to enter mathematical
| expressions like 1/45 and not just numbers. It seemed to work fine for
| a week or so. But then - when I tried to use it to modify a previously
| written spreadsheet the above line threw a "Run-time error 438 -
| Object doesn't support this property or method" error on the stepsize
| 1. Somewhat curiously, I found that when I typed ?Evaluate("1") in the
| immediate window I got the error but ?Evaluate("3") returned 3 as
| expected. I experminented with several old workbooks and found that
| for all of the ones I wrote in Excel 2000 (or earlier) and some that I
| wrote in Excel 2003 I get the error when I type ?Evaluate("n") for
| some but not all small n. Curiously, sometimes "1" is ok but it balks
| at "2" or "3". Any idea what is going on?
|
| The workaround was easy:
|
| stepSize = CDec(Evaluate("=" & InputBox("Enter step size")))
|
| seems ok.
|
| Is Evaluate supposed to work this way or is it a bug?
|
| -John Coleman
|


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
Evaluate "nested-merge" function? Mikael Lindqvist Excel Worksheet Functions 3 November 3rd 08 04:53 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
How does Excel evaluate embedded "IF" statements Kc-Mass Excel Programming 5 January 6th 07 03:36 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


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