#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If, And


Can someone help me out with a fairly simple formula?
I want a message to pop up saying " Please fill in the price".

The function needs to say, If C100, and F10=0 then please fill in the
price.

It should be a simple function, but IF AND statements lose me!!


--
M3Cobb
------------------------------------------------------------------------
M3Cobb's Profile: http://www.excelforum.com/member.php...o&userid=24986
View this thread: http://www.excelforum.com/showthread...hreadid=389005

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default If, And

One way:

If Range("C10").Value 10 And Range("F10").Value = 0 Then _
MsgBox "Please fill in the price"



In article ,
M3Cobb wrote:

Can someone help me out with a fairly simple formula?
I want a message to pop up saying " Please fill in the price".

The function needs to say, If C100, and F10=0 then please fill in the
price.

It should be a simple function, but IF AND statements lose me!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default If, And

If ((Range("C10").Value 0) And (Range("F10").Value=0)) Then _
MsgBox "Please fill in the price"

The trickiest part of Ifs with Ands, Ors, or a combination of them is to
make sure the conditions get put in the right order to be executed properly.
For example:
If A=1 And B=2 Or C=3
Does this mean:
If (A=1 And (B=2 Or C=3))
Or does it mean:
If ((A=1 And B=2) Or C=3)
Or, worse, if there are Boolean variables or Variants involved, does it mean
If (((A=1) And B)=2) Or C) = 3

That is why I like using the brackets, even if they are redundant - it helps
me make sure the code is correct and helps me to see my intention if I go
back to debug the code later.
--
- K Dales


"M3Cobb" wrote:


Can someone help me out with a fairly simple formula?
I want a message to pop up saying " Please fill in the price".

The function needs to say, If C100, and F10=0 then please fill in the
price.

It should be a simple function, but IF AND statements lose me!!


--
M3Cobb
------------------------------------------------------------------------
M3Cobb's Profile: http://www.excelforum.com/member.php...o&userid=24986
View this thread: http://www.excelforum.com/showthread...hreadid=389005


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default If, And

I would do it by putting the Cell values into variables and testing their
condition, something like this:

Range("C10").Select
A=ActiveCell
Range("F10").Select
B=ActiveCell

If A0 And B=0 Then
MsgBox ("Enter Data In Cell F10")
End If

This would obviously need expanding with some validation of the datafor the
cells, but I think you should get the general idea.

HTH


Neil
www.nwarwick.co.uk

"M3Cobb" wrote:


Can someone help me out with a fairly simple formula?
I want a message to pop up saying " Please fill in the price".

The function needs to say, If C100, and F10=0 then please fill in the
price.

It should be a simple function, but IF AND statements lose me!!


--
M3Cobb
------------------------------------------------------------------------
M3Cobb's Profile: http://www.excelforum.com/member.php...o&userid=24986
View this thread: http://www.excelforum.com/showthread...hreadid=389005


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



All times are GMT +1. The time now is 08:19 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"