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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verify Cell Vaule and Prompt User if Necessary

Status
Not open for further replies.

b31luv

Technical User
Feb 21, 2002
171
US
I'm not trying to become a professional programmer in Excel. I just want to make a spreadhseet give a message, if necessary, based on inputted value in a cell.

This is what I have

If Cell("b9").Value = 1 Then
MsgBox ("Please Enter either 1, 2, or 3"), vbExclamation
Else

End If


Actually this is all have. Nothing happens when I input any value so I kind of figured that this isn't right. you've guessed it, I'm not a rocket scientist

Thanks in Advance for any assistance

 
Why not simply use menu Data -> Validation ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 





Hi,

Really??? I can here the user now, "But I ENTERED a 1! Grrrrr!!!"
Code:
If Cell("b9").Value = 1 Then
MsgBox ("Please Enter either 1, 2, or 3"), vbExclamation
Else

End If
This might be better...
Code:
If Range("b9").Value < 1 Or Range("b9").Value >3 Or INT(Range("b9").Value) <> Range("b9").Value Then
  MsgBox ("Please Enter either 1, 2, or 3"), vbExclamation
End If
Why not use Data > Validation, built into Excel, using no VBA code at all?


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Pretty funny huh?

I knew about Validation but I only used it for developing List.

Thanks to each of you for your time.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top