Results 1 to 2 of 2

Problem with Intersect(Target)

Threaded View

  1. #1
    Registered User
    Join Date
    11-26-2010
    Location
    Italia
    MS-Off Ver
    Excel 2003
    Posts
    20

    Question Problem with Intersect(Target)

    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
    Last edited by fcarboni; 06-05-2012 at 09:09 AM. Reason: ban from moderator!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1