Hi,
I am getting "error -13 type mismatch "in this line below from my code
"If Rng1.Value >= 0 And Rng2.Value <= 999999 Then"
Basically I want to calculate formula only if values are greater than 0 and less than 099999.
Any help would be appreciated.
Thanks,
Vik
'mycal() is function created by me to caluculate X.
Sub mycal()
Dim thecountX As Integer
Dim Rng1 As range, Rng2 As range
Set Rng1 = range("C1:C25")
Set Rng2 = range("B1:B25")
If Rng1.Value >= 0 And Rng2.Value <= 999999 Then
'Here We are calculating value of X and storing in varilable "thecountX".
thecountX = (range("C10") * range("C8") - range("C9") * range("B13")) / range("C10") + range("B13")
Else
MsgBox "Give value between 0 and 999999999999"
End If
'Here we are displaying the value of X from variable "thecountX".
MsgBox "the count is " & thecountX
'Endsub is used to end any function.
End Sub
I am getting "error -13 type mismatch "in this line below from my code
"If Rng1.Value >= 0 And Rng2.Value <= 999999 Then"
Basically I want to calculate formula only if values are greater than 0 and less than 099999.
Any help would be appreciated.
Thanks,
Vik
'mycal() is function created by me to caluculate X.
Sub mycal()
Dim thecountX As Integer
Dim Rng1 As range, Rng2 As range
Set Rng1 = range("C1:C25")
Set Rng2 = range("B1:B25")
If Rng1.Value >= 0 And Rng2.Value <= 999999 Then
'Here We are calculating value of X and storing in varilable "thecountX".
thecountX = (range("C10") * range("C8") - range("C9") * range("B13")) / range("C10") + range("B13")
Else
MsgBox "Give value between 0 and 999999999999"
End If
'Here we are displaying the value of X from variable "thecountX".
MsgBox "the count is " & thecountX
'Endsub is used to end any function.
End Sub