ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If, And (https://www.excelbanter.com/excel-programming/335148-if.html)

M3Cobb[_4_]

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


JE McGimpsey

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!!


K Dales[_2_]

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



Neil

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




All times are GMT +1. The time now is 11:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com