#1   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,316
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"