With Range(...)
For ...
If ...
End If
Next
End With
I did write it after the Next CD and it didn't give me any error but the code didn't work. the code didn't fire upAs I said before it must go after the Next Cd line
I am a VBA Beginner so i may not able to ident it correctlyThe thing to remember when working with multi-line blocks in VBA (like "If/End If", "With/End If", "For/Next"), the LAST one started must be the FIRST one to close (and likewise, the FIRST one started must be the LAST one to close).
If you indent your code properly, it make it very easy to see and follow along, i.e.
Rich (BB code):With Range(...) For ... If ... End If Next End With
here is the code with the way you suggested. i didn't get any error but the code didn't fire up. as you can see the 2% remains while it should have replaced by ZeroPost the code when you tried what I suggested & show the error you get.
Jul-2022 | |||
Renewal of Exp CD's | New Purchase Date | Interest Rate | Interest Amount |
$3,000 | 4-Jun-22 | 2% | $5 |
2% | | ||
2% | | ||
2% | |
Forget the indenting for a moment (that just makes it easier to visualize).I am a VBA Beginner so i may not able to ident it correctly
I am getting the same error in a normal module.Put this code in a normal module & run it. Then with the code you posted in post#15 try changing a value in J47:J71
Sub Changeevent()Forget the indenting for a moment (that just makes it easier to visualize).
Note what I said in my previous post, and take a look at the pattern (I color-coded it to make it obvious).
If you understand that, then it will become evident exactly what you need to do to fix your code.