Format statement no longer throws an error

P

PF

I had code running in Excel 97 that would throw an error, but now that I am running Excel 2003 it does not.

Format$("0.5","General"

It used to throw error 5 (Invalid procedure call or argument), but now it returns "Ge5eral". Is this a documented change?
 
R

Rob van Gelder

You're mixing Worksheet NumberFormat expression with VBA format.

It's interpretting the N in "General" as a minute (hh:nn:ss)

If you want to format a cell as General:
ActiveCell.NumberFormat = "General"


--
Rob van Gelder - http://www.vangelder.co.nz/excel


PF said:
I had code running in Excel 97 that would throw an error, but now that I
am running Excel 2003 it does not.
Format$("0.5","General")

It used to throw error 5 (Invalid procedure call or argument), but now it
returns "Ge5eral". Is this a documented change?
 
D

Dave Peterson

Try:

Format$(0.5, "General Number")

(not sure why you had "0.5" in double quotes, either.)
 
W

Wei-Dong Xu [MSFT]

Hi,

Thanks for posting in the community!

I agree with Rob and Dave. If you have any other questoins, please feel free to let me know.

Enjoy a nice weekend!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

PF

That's all interesting information, but it didn't really
answer my question, which is why does this statement not
throw an error while it did in previous versions.
-----Original Message-----
Hi,

Thanks for posting in the community!

I agree with Rob and Dave. If you have any other
questoins, please feel free to let me know.
 
W

Wei-Dong Xu [MSFT]

Hi PF,

Thank you for replying!

Currentlly we are performing some research on this problem, and we will reply you ASAP if we get any results!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jim Vita

Hi,

It sure looks like the string "General" is being interpreted as a format
string and that your value is being inserted at the "n" position. I will
have to investigate if the behavior Format in Excel 2003 has changed. I'll
post another reply as soon as I have finished investigating.

Thanks for your patience.

Thanks,

Jim

Jim Vita
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Top