Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can you check two numbers then place another number in a cell? 1

Status
Not open for further replies.

Tarquine

Vendor
Jan 15, 2000
38
GB
Sorry the Subject line was so long.&nbsp;&nbsp;I bet you can't make head or tail of what I am trying to do.<br><br>Well, I have two known numbers in two seperate cells.&nbsp;&nbsp;I would like to check if either are greater than 2.&nbsp;&nbsp;<br><br><font color=red>If the numbers in either cell is greater than 2</font>, <u>Then a third cell needs to read 2</u>.&nbsp;&nbsp;<br><br><font color=red>If however the numbers in both cells are less than 2</font>, then <u>the same third cell needs to read 0 (Zero)</u>.<br><br>Has anyone got any ideas on how to do this?<br><br>Regards<br><br>Tarquine
 
Cells??? Are you in Access or Excel?<br>VBA way:<br>If myvalue &gt; 2 or Somevalue &gt; 2 then<br>ThirdValue = 2<br>Else<br>ThirdValue = 0<br>End if<br>
 
If you are talking about Fields in a Table as in Access, and you need the third field stored in the table; build an update query to calculate the third field. If you are wanting to display the third field as a calculation in a form or report, use a text box and DougP's Code to calculate the value.<br><br>If you are talking about Excel, the third cells formula would be:<br><br>=IF(OR(Cell_1&gt;2,Cell_2&gt;2),2,0)<br>Or<br>=IF(Cell_1&gt;2,2,If(Cell_2&gt;2,2,0))<br><br>Bob Crawford<br>
 
My code has a typo in it. Should be<br>If myvalue &gt; 2 or Somevalue &lt; 2 then&nbsp;&nbsp;&nbsp;' notice the &lt; &gt; <br>
 
<font color=red>Thanks very much for all the replys that were posted</font>.&nbsp;&nbsp;I will try to remember next time to give all relevant information concerning what software I am using, sorry about that.<br><br>By the way I have put them all to good use and everything went well.<br><br>Thanks again<br><br>Regards<br><br>Tarquine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top