ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if then and do - DA (https://www.excelbanter.com/excel-programming/436498-if-then-do-da.html)

DA[_2_]

if then and do - 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

Tim Williams[_2_]

if then and do - DA
 

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


"DA" wrote in message
...
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




JBeaucaire[_131_]

if then and do - DA
 
Maybe this:

Sub fortyeightMIRBal()

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

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

Loop

End Sub


--
"Actually, I *am* a rocket scientist." -- JB
(www.MadRocketScientist.com)

Your feedback is appreciated, click YES if this post helped you.


"DA" wrote:

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
.



All times are GMT +1. The time now is 08:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com