Format statement no longer throws an error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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?
 
Try:

Format$(0.5, "General Number")

(not sure why you had "0.5" in double quotes, either.)
 
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.
 
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.
 
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.
 
Hi

This is not a bug, it is by design and exhibits the same behavior in 2000,
XP, and 2003. Starting with Office 200, the word "General" is not
interpreted as a formatting type, but instead as a user-defined format
string. The "n" in General stands for minutes so the format causes the
following to occur. The target is converted to a time and the minutes place
of the time is inserted into the string.

Thanks,

Jim

Jim Vita
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thank you very much for your answer. I will make code changes as needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top