MSG box if

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
I need a MSG box to come up if any cells from A1:A10 AND/OR C1:C10 contain
BOTH a "Y" and a "N". They can contain ONLY either "Y's" or "N's"....not both.
Any suggestions?

Thanks,
Tom
 
I selected range A1:A10 and C1:C10 and assigned the range name of DataRange
to the selected cells. This was done in Sheet1 of the workbook. In the
sheet module for Sheet1 I assigned the following event to Worksheet_Change
event:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim r As Range
Dim intCell As Integer

Set r = Range("DataRange")

For intCell = 1 To r.Cells.Count
If r.Cells(intCell) = "Y" Or r.Cells(intCell) = "N" Then
MsgBox "Yo! What's up?"
End If
Next intCell

Set r = Nothing
Exit Sub

End Sub
 
Hi Tom,

data >> validation

allow List

as list enter Y,N,y,n

define error message.

Applicable in your case?

Regards,
Ivan
 
That did it...Thanks Kevin!

Kevin B said:
I selected range A1:A10 and C1:C10 and assigned the range name of DataRange
to the selected cells. This was done in Sheet1 of the workbook. In the
sheet module for Sheet1 I assigned the following event to Worksheet_Change
event:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim r As Range
Dim intCell As Integer

Set r = Range("DataRange")

For intCell = 1 To r.Cells.Count
If r.Cells(intCell) = "Y" Or r.Cells(intCell) = "N" Then
MsgBox "Yo! What's up?"
End If
Next intCell

Set r = Nothing
Exit Sub

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top