ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MSG box if (https://www.excelbanter.com/excel-programming/361913-msg-box-if.html)

tom

MSG box if
 
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

Kevin B

MSG box if
 
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

--
Kevin Backmann


"Tom" wrote:

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


Ivan Raiminius

MSG box if
 
Hi Tom,

data validation

allow List

as list enter Y,N,y,n

define error message.

Applicable in your case?

Regards,
Ivan


tom

MSG box if
 
That did it...Thanks Kevin!

"Kevin B" wrote:

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

--
Kevin Backmann


"Tom" wrote:

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



All times are GMT +1. The time now is 02:48 PM.

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