How do I make this code shorter? Its Result should be given to
Hey thanks this is the exact one ,Im trying to modify the values of this code
"C = Cl + 2 - (Cl + 1) Mod 3" so it will compute after 3 columns. but I cant
get the exact value. Need help thanks.
Jay
"Dana DeLouis" wrote:
C = 3 * Int((Cl + 4) / 3) - 2
Slightly better might be just an offset equation...
Sub Try2()
Dim Rw As Long
Dim Cl As Long
Dim C As Long
Rw = ActiveCell.Row
Cl = ActiveCell.Column
If Not (Rw = 2 And Rw <= 12 And _
Cl = 2 And Cl <= 22) Then Exit Sub
'// Offset by 2,1,or 0
C = Cl + 2 - (Cl + 1) Mod 3
'// Fill in Formula down to row 12
Range(Cells(Rw, C), Cells(12, C)).FormulaR1C1 = "=RC[-2]+RC[-1]"
End Sub
- - -
HTH :)
Dana DeLouis
|