Hi,

I getting error 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 appriciated.

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

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to