wrong assumption.
Be carefull to assign a localized string to the value property.
goes for dates and decimal numbers... you're asking for trouble
Format is internationally aware...thus Format(1.2345,"Percent")
produces a string "123,45%" on a system with a comma as decimal
separator.
It's inserted as a string. LEFT aligned. You COULD use it in formulas
because excel will try to evaluate cell references used in formulas as
numbers... but it's shaky.. (it will only be converted to a VALUE(
number) when the user presses F2 enter... if you leave it a string
then opening the sheet in a different locale spells trouble.
It makes far more sense to assign a Double to .Value
THEN format it using numberformat.
When dates can be involved it may get worse so for
safety I often just use .Value2 (and .Numberformat)
If you want to experiment, just play around with Regional Settings.
--
keepITcool
|
www.XLsupport.com | keepITcool chello nl | amsterdam
Jim Cone wrote :
Thank you for pointing that out, I will keep it for future reference.
Would I assume correctly that: .Value = Format$(StartVal, "Percent")
would not create a problem?
For others reading this, it should be noted that formatting and
calculation should not be done inside a loop, if it can be avoided.
Regards,
Jim Cone
San Francisco, USA
"keepITcool" wrote in message
ft.com...
Jim,
note that writing Format(1.23,"%") it will not
work in situations where users have a comma as decimal separator.
I think that a better way to do this would be:
Sub AlsoLoop()
Dim Cnt As Long
Dim NumToFill As Long
NumToFill = Worksheets(1).Range("a1")
ActiveCell.Resize(NumToFill).NumberFormat = "0.00%"
For Cnt = 1 To NumToFill
ActiveCell.Cells(Cnt, 1).Value = Application.Round(Cnt / NumToFill, 4)
Next Cnt
End Sub
--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam