Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
GREATER THAN
Hi,
Can anyone help me with some code, iwant to use an if statement, declaring that if a varible is greater then 0 then do my then statement. I cannot seem to get it right i am using if variable name 0 then my action |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
GREATER THAN
sub Tester2()
Dim num as long num = 10 - int(rnd()*20+1) if num 0 then msgbox num & " is greater than 0" else msgbox num & " is less than or equal to 0" End if End Sub -- Regards, Tom Ogilvy wrote in message oups.com... Hi, Can anyone help me with some code, iwant to use an if statement, declaring that if a varible is greater then 0 then do my then statement. I cannot seem to get it right i am using if variable name 0 then my action |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
GREATER THAN
You've got the syntax correct.
If it doesn't work perhaps the variable isn't numeric or perhaps it's < or = 0? As a simple example, the below declares intTestNumber as an Integer then sets it to the value of Cell A1. Next it tests to see if it's greater than 0. If it is, it sets Cell A1 back to Zero. Dim intTestNumber As Integer intTestNumber = Range("A1").Value if intTestNumber 0 Then Range("A1").Value = 0 Hope that helps. CB Hamlyn wrote in message oups.com... Hi, Can anyone help me with some code, iwant to use an if statement, declaring that if a varible is greater then 0 then do my then statement. I cannot seem to get it right i am using if variable name 0 then my action |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
If formula: if A1 is greater than B1 and A1 is greater than zero.. | Excel Discussion (Misc queries) | |||
Greater than and less than | Excel Discussion (Misc queries) | |||
Greater than | Excel Discussion (Misc queries) | |||
Last Value Greater Than Zero | Excel Discussion (Misc queries) | |||
IF greater than...IF less than....====== | Excel Discussion (Misc queries) |