View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default How to Make a Loop count by 1% not 1


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