do until loop and output

arom

New Member
Joined
Jul 24, 2008
Messages
23
I will put any number in cell B2. This number is called 'd2' and will be referenced in the code.

i want to write code that will do the following:

let p1 = .01
then do p1 = p1 + d2 until p1 = 1 - d2 + .01 and put these numbers in column C.

any ideas??

thanks!!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
This macro seems to follow your logic, but I can't fathom your number series yet. What number values are you dealing with? If you can explain your number series, I could put checks into the macro to keep it from spinning off the page like it's doing for me right now.
Code:
Sub NumSeries()
Dim p1 As Double, d2 As Double, NR As Long
p1 = 0.01
d2 = Range("B2")
NR = 1

    Do
        p1 = p1 + d2
        Cells(NR, "C") = p1
        NR = NR + 1
        If p1 >= 1 - d2 + 0.01 Then Exit Do
    Loop

End Sub

I added the >= instead of just = to at least get it to stop when it passes the point that it would NEVER match.
 
Upvote 0
actually, that's fine. i can leave it as >= for now. thank you so much for your help!! i really appreciate it!
 
Upvote 0
arom

What is the series?

What values are you using in B2?
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top