Good night, I´m writing this code for a database but when i try to run it i keep getting runtime error in the line
Sub total()
Application.Calculation = xlManual
Dim ctotal As Integer, cposible As Integer, contador As Integer
For contador = 2 To 9551 'The quantity of items in my database
If Right(Range(contador, 6).Value, 3) = "c/3" Then 'C/3 is the value that 'might be at the end of a String value
ctotal = (Range(contador, 15).Value * 2) - Range(contador, 12).Value
cposible = ctotal / 3
cposible = ctotal - (cposible * 3)
If cposible < 2 Then
ctotal = ctotal + cposible
Else
ctotal = ctotal - cposible
End If
Range(contador, 22).Value = ctotal
End If
Next contador
Application.Calculation = xlAutomatic
End Sub
I keep getting the runtime error 1004 in this line
ctotal = (Range(contador, 15).Value * 2) - Range(contador, 12).Value
How can i fix that error?
Thanks
Sub total()
Application.Calculation = xlManual
Dim ctotal As Integer, cposible As Integer, contador As Integer
For contador = 2 To 9551 'The quantity of items in my database
If Right(Range(contador, 6).Value, 3) = "c/3" Then 'C/3 is the value that 'might be at the end of a String value
ctotal = (Range(contador, 15).Value * 2) - Range(contador, 12).Value
cposible = ctotal / 3
cposible = ctotal - (cposible * 3)
If cposible < 2 Then
ctotal = ctotal + cposible
Else
ctotal = ctotal - cposible
End If
Range(contador, 22).Value = ctotal
End If
Next contador
Application.Calculation = xlAutomatic
End Sub
I keep getting the runtime error 1004 in this line
ctotal = (Range(contador, 15).Value * 2) - Range(contador, 12).Value
How can i fix that error?
Thanks