L
L. Howard
I wrote this code to select a row in column A and add/subtract a specific amount to that row value and all the rows below it.
I now find that if the number is say 2.5 it adds 3. Or 1.3 is added as 1.
Is that fixable?
Thanks.
Howard
Sub Add_Subt()
Dim aRng As Range
Dim AddSub As Variant
Dim i As Long, j As Long
Dim myVals As Variant
Dim r As Range, c As Range
AddSub = Application.InputBox("Enter the row number where to start" & vbCr & _
"then a comma and the value " & vbCr & _
"you want to add or subtract with no space. " & vbCr & _
"Where row 9 and below you will add 11." _
& vbCr & vbCr & " Example 9,11 " _
& vbCr & " ", "We add & subtract", Type:=2)
If AddSub = "" Or AddSub = "False" Then Exit Sub
myVals = Split(AddSub, ",")
i = myVals(0)
j = myVals(1)
'MsgBox i & " " & j
Set r = Range("A" & i, Range("A1").End(xlDown))
For Each c In r
If c.Value > 0 Then
c.Value = c.Value + j
End If
Next
End Sub
I now find that if the number is say 2.5 it adds 3. Or 1.3 is added as 1.
Is that fixable?
Thanks.
Howard
Sub Add_Subt()
Dim aRng As Range
Dim AddSub As Variant
Dim i As Long, j As Long
Dim myVals As Variant
Dim r As Range, c As Range
AddSub = Application.InputBox("Enter the row number where to start" & vbCr & _
"then a comma and the value " & vbCr & _
"you want to add or subtract with no space. " & vbCr & _
"Where row 9 and below you will add 11." _
& vbCr & vbCr & " Example 9,11 " _
& vbCr & " ", "We add & subtract", Type:=2)
If AddSub = "" Or AddSub = "False" Then Exit Sub
myVals = Split(AddSub, ",")
i = myVals(0)
j = myVals(1)
'MsgBox i & " " & j
Set r = Range("A" & i, Range("A1").End(xlDown))
For Each c In r
If c.Value > 0 Then
c.Value = c.Value + j
End If
Next
End Sub