Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If formula: if A1 is greater than B1 and A1 is greater than zero.. Jason Excel Discussion (Misc queries) 2 April 5th 10 06:11 PM
Greater than and less than Farmer Ted Excel Discussion (Misc queries) 4 January 12th 10 04:19 AM
Greater than oldjay Excel Discussion (Misc queries) 4 August 8th 09 06:27 PM
Last Value Greater Than Zero Anto111 Excel Discussion (Misc queries) 7 May 31st 08 06:56 PM
IF greater than...IF less than....====== BenJAMMIN Excel Discussion (Misc queries) 3 May 29th 05 03:41 PM


All times are GMT +1. The time now is 04:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"