View Full Version : message box for text value


whhaatt
07-30-2008, 08:27 AM
Is it possible to setup excel (VBA) to return a msgbox if certain text is entered into a cell - and if not then no msg is displayed?

ie if cell value is "test" then msg box appears with msg
if cell value is anything else then msg box does not appear


If possible can this be done on a range of cells - please remember that msg box is for text value and not numeric

Thankyou

chergh
07-31-2008, 12:39 AM
you want to use the sheetchange event of the workbook.


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)


'range defined here is C3 - J10

If Target.Column >= 3 And _
Target.Column <= 10 And _
Target.Row >= 3 And _
Target.Row <= 10 And _
Target.Value = "test" Then

MsgBox ("You win")

End If

End Sub


This is case sensitive so use:


lcase(Target.Value)


If you don't care about case.