Hi,
I need to controll if into a range of cell the max item will be two.
If the user write the vlue and play enter, or right arrows the function ready, if the user play the mouse into another cell or use a left, up, down arrows the controll don't go.
any ideas???
thank
Fabrizio
![]()
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("D12:T385")) Is Nothing Then Exit Sub Else Dim stDocName1 As Variant Dim stDocName2 As Variant Dim stDocName3 As String stDocName1 = ActiveCell.Row stDocName2 = ActiveCell.Column stDocName3 = "Sorry" & vbCrLf & "two operator will be in Holiday into some day" Select Case stDocName2 Case 4 To 9 Range(Cells(stDocName1, 4), Cells(stDocName1, 9)).Select If WorksheetFunction.Count(Selection) > 2 Then MsgBox stDocName3, vbExclamation, "Holidays Planning" Cells(stDocName1, stDocName2).Value = Null Cells(stDocName1, stDocName2).Select End If Case 10 To 14 Range(Cells(stDocName1, 10), Cells(stDocName1, 14)).Select If WorksheetFunction.Count(Selection) > 2 Then MsgBox stDocName3, vbExclamation, "Holidays Planning" Cells(stDocName1, stDocName2).Value = Null Cells(stDocName1, stDocName2).Select End If Case 15 To 20 Range(Cells(stDocName1, 15), Cells(stDocName1, 20)).Select If WorksheetFunction.Count(Selection) > 2 Then MsgBox stDocName3, vbExclamation, "Holidays Planning" Cells(stDocName1, stDocName2).Value = Null Cells(stDocName1, stDocName2).Select End If End Select End If Application.EnableEvents = True End Sub











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks