View Single Post
  #3   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

or
'-----------------------
Sub GoodLoop()
Dim Cnt As Double
Dim StartVal As Double
Dim NumToFill As Double
Dim dblIncrement As Double

NumToFill = Sheets("Control").Range("E17")
dblIncrement = 1 / NumToFill
StartVal = dblIncrement

For Cnt = 0 To NumToFill - 1
ActiveCell.Offset(Cnt, 0).Value = Format(StartVal, "0.00%")
StartVal = StartVal + dblIncrement
Next Cnt

End Sub
'---------------------------------

Jim Cone
San Francisco, USA




"MichaelC" wrote in message
...
I have a macro that performs a looped calculation stepping up the input value
by 1 for each count.
I want to use the same macro to perform the same looped calculation starting
at 1% and ending at 100%, but have been unsuccessful.
My power Programming book is silent on this. I would much appreciate any
help.
Here is my macro:
Sub GoodLoop()
StartVal = 1
NumToFill = Sheets("Control").Range("E17")
ActiveCell.Value = StartVal
For Cnt = 0 To NumToFill - 1
ActiveCell.Offset(Cnt, 0).Value = StartVal + Cnt
Next Cnt

End Sub