Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If then statement in excell?

How do I create an If then statement in excell?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default If then statement in excell?

If something = True then
'do something
End If

or did you mean in a worksheet formula ?

=IF(A1="Oranges","Fruity","No fruit")

Tim

"BMatson" wrote in message
...
How do I create an If then statement in excell?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default If then statement in excell?

=IF(test condition, true action, false action)
Help on the function will give more details. Here are a couple of examples:
=IF(A1=4, "A1 does equal 4","") shows blank if A1 doesn't = 4.
=IF(A1=A5,(A1+A5)*3,0) ' adds A1+ A5 and multiplies result by 3 if A1=A5,
results is zero if not equal.
=IF(AND(B1=3,X5="Ripe"),"conditions met","conditions not met")

IF statements can be nested, with another IF statement being placed in
either the True or False action portions of each. You can carry this on to a
total of 7 nested functions in pre-2007 versions of Excel.

"BMatson" wrote:

How do I create an If then statement in excell?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default If then statement in excell?

In my previous post I showed how to use the worksheet function IF. Now,
since this is the Programming group, perhaps you're looking for VBA code? In
that case:

Sub Dummy()
IF Range("X1").Value = 4 Then
Range("X2").Value = "X1 is 4" ' or some math or whatever
Range("X3").Value = "I said: X1 is 4!" ' can use multiple statements
End if
End Sub

there is also the IF...Then...Else variation, and the If...Then...ElseIf...
variation. VBA Help has discussions of these.

"BMatson" wrote:

How do I create an If then statement in excell?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default If then statement in excell?

Hit [Enter] too soon!

Sub TestIfThenElse()
IF Range("X1").Value = 4 Then
'code to perform when condition is true
Else
'code to perform when condition is not true
End If

You can have multiple code statements in both the Then section and the Else
section if you need them.

"BMatson" wrote:

How do I create an If then statement in excell?



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
Is it possible to change the normal excell icon on an excell file? Romileyrunner1 Excel Worksheet Functions 7 September 8th 09 08:38 PM
Excell 2000 IF Statement LPS Excel Discussion (Misc queries) 1 September 18th 08 02:05 AM
Excell Books how to create a financial statement? (4 dummies) susy Excel Discussion (Misc queries) 2 November 5th 07 09:05 PM
how do you open an excell email attacment, if I dont have excell Gary Excel Discussion (Misc queries) 1 February 22nd 06 10:26 PM
If then statement Excell 2000 holy dog Setting up and Configuration of Excel 2 December 16th 05 04:47 PM


All times are GMT +1. The time now is 08:02 AM.

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

About Us

"It's about Microsoft Excel"