if then and do - DA

D

DA

OK, folks. I've been away from macros for too long and can't get it
right for something this simple! I think i keep reverting to Fortran
days! Kindly help.

Here is my sorry-assed attempt at a macro that is supposed to copy
from one cell and paste its value to another, until some third cell is
close to zero. The purpose of this is to avoid having to use
iterative mode, which I don't like becasue it masks other programming
errors.

Though I know there are always more creative ways to do these things,
it might be best if you just correct what i've done in the most simple
way, so that i can re-learn the basics. of ifs, thens, and loops.

Thanks much
Dean

Option Explicit
Sub fortyeightMIRBal()

Dim j As Integer
Dim myvalue As Variant
For j = 1 To 1000
myvalue = Range("EndingIRBalance48").Value
If Abs(myvalue) > 0.001 Then
Range("TotalInterest48").Select
Selection.Copy
Range("IntReserveBalance48").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Else: GoTo 100
End If
Next j
100
End Sub
 
T

Tim Williams

Option Explicit
Sub fortyeightMIRBal()

Dim j As Integer

For j = 1 To 1000
If Abs(Range("EndingIRBalance48").Value) > 0.001 Then
Range("IntReserveBalance48").value =
Range("TotalInterest48").value
Else
Exit for
End If
Next j

End Sub



Tim
 
J

JBeaucaire

Maybe this:

Sub fortyeightMIRBal()

Do While Abs(Range("EndingIRBalance48")) > 0.001

Range("IntReserveBalance48").Value = Range("TotalInterest48").Value

Loop

End Sub
 

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

Similar Threads


Top