Home |
Search |
Today's Posts |
#1
|
|||
|
|||
IF NOT
I am having a little difficulty trying to write a formula to display a
message if a certain cell does not contain the correct information. Can anyone please help me with this. I.e. If cell A1 does not contain 1 or 2 or 3 then display message "reenter number" Cheers |
#2
|
|||
|
|||
Hi
I would suggest having a look at Data|Validation. It will do just what you want! Have a look he http://www.contextures.com/xlDataVal01.html for more information and examples. -- Andy. "Nick" wrote in message ... I am having a little difficulty trying to write a formula to display a message if a certain cell does not contain the correct information. Can anyone please help me with this. I.e. If cell A1 does not contain 1 or 2 or 3 then display message "reenter number" Cheers |
#3
|
|||
|
|||
I have looked at the site and nothing seems to work or be useful. I'm working
in Visual basic within a long macro. Anyone got any tips on the code to possibly use. At the moment I have If Range("B12") = "1" or "2" or "3" Then Range("A1").Select Else If Range("B12") Is Not "1" or "2" or "3" Then MsgBox "Re-enter Number" An error message is displayed saying Compile error: Type Mismatch Any ideas people "Andy B" wrote: Hi I would suggest having a look at Data|Validation. It will do just what you want! Have a look he http://www.contextures.com/xlDataVal01.html for more information and examples. -- Andy. "Nick" wrote in message ... I am having a little difficulty trying to write a formula to display a message if a certain cell does not contain the correct information. Can anyone please help me with this. I.e. If cell A1 does not contain 1 or 2 or 3 then display message "reenter number" Cheers |
#4
|
|||
|
|||
"2" and "3" are not boolean values, hence the Type Mismatch error.
If [B12] = 1 Or [B12] = 2 Or [B12] = 3 Then [A1].Select Else MsgBox "Re-enter Number" [B12].Select End If Except for the [A1].Select, this could all be done by entering a Data|Validation criteria from the worksheet menu, as has been previously suggested in both of your related threads. Jerry Nick wrote: I have looked at the site and nothing seems to work or be useful. I'm working in Visual basic within a long macro. Anyone got any tips on the code to possibly use. At the moment I have If Range("B12") = "1" or "2" or "3" Then Range("A1").Select Else If Range("B12") Is Not "1" or "2" or "3" Then MsgBox "Re-enter Number" An error message is displayed saying Compile error: Type Mismatch Any ideas people "Andy B" wrote: Hi I would suggest having a look at Data|Validation. It will do just what you want! Have a look he http://www.contextures.com/xlDataVal01.html for more information and examples. -- Andy. "Nick" wrote in message ... I am having a little difficulty trying to write a formula to display a message if a certain cell does not contain the correct information. Can anyone please help me with this. I.e. If cell A1 does not contain 1 or 2 or 3 then display message "reenter number" Cheers |
#5
|
|||
|
|||
With .Range("B12")
If .Value = "1" or .Value = "2" or .Value = "3" Then Range("A1").Select Else MsgBox "Re-enter Number" End If End With -- HTH Bob Phillips "Nick" wrote in message ... I have looked at the site and nothing seems to work or be useful. I'm working in Visual basic within a long macro. Anyone got any tips on the code to possibly use. At the moment I have If Range("B12") = "1" or "2" or "3" Then Range("A1").Select Else If Range("B12") Is Not "1" or "2" or "3" Then MsgBox "Re-enter Number" An error message is displayed saying Compile error: Type Mismatch Any ideas people "Andy B" wrote: Hi I would suggest having a look at Data|Validation. It will do just what you want! Have a look he http://www.contextures.com/xlDataVal01.html for more information and examples. -- Andy. "Nick" wrote in message ... I am having a little difficulty trying to write a formula to display a message if a certain cell does not contain the correct information. Can anyone please help me with this. I.e. If cell A1 does not contain 1 or 2 or 3 then display message "reenter number" Cheers |
#6
|
|||
|
|||
I have tried entering the suggested code. The message box is now displayed
everytime I press my printpreview button that the macro is assigned to, even if the number in the cell is correct. Im not 100% confident on how to use data validation, just thought there would be simple way of using visual basic to enter the code. Any other suggestions please "Jerry W. Lewis" wrote: "2" and "3" are not boolean values, hence the Type Mismatch error. If [B12] = 1 Or [B12] = 2 Or [B12] = 3 Then [A1].Select Else MsgBox "Re-enter Number" [B12].Select End If Except for the [A1].Select, this could all be done by entering a Data|Validation criteria from the worksheet menu, as has been previously suggested in both of your related threads. Jerry Nick wrote: I have looked at the site and nothing seems to work or be useful. I'm working in Visual basic within a long macro. Anyone got any tips on the code to possibly use. At the moment I have If Range("B12") = "1" or "2" or "3" Then Range("A1").Select Else If Range("B12") Is Not "1" or "2" or "3" Then MsgBox "Re-enter Number" An error message is displayed saying Compile error: Type Mismatch Any ideas people "Andy B" wrote: Hi I would suggest having a look at Data|Validation. It will do just what you want! Have a look he http://www.contextures.com/xlDataVal01.html for more information and examples. -- Andy. "Nick" wrote in message ... I am having a little difficulty trying to write a formula to display a message if a certain cell does not contain the correct information. Can anyone please help me with this. I.e. If cell A1 does not contain 1 or 2 or 3 then display message "reenter number" Cheers |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|