Hi,
Is it possible to have two Worksheet_SelectionChange events for the same worksheet if so how. If not what options do i have?
Two Worksheet_selectionchange
-
-
Re: Two Worksheet_selectionchange
Why would you need two of them?
-
Re: Two Worksheet_selectionchange
here is the code i have for the first one
Code
Display MorePrivate Sub Worksheet_SelectionChange(ByVal Target As Range) Dim msg As String Dim msg2 As String Dim NewDate As Date Dim c As Range If Target.Cells.Count > 1 Then Exit Sub If Not Intersect(Target, Range("AF8:AF60")) Is Nothing Then msg = InputBox("Please Enter A Date..." & vbLf & vbLf & "(MM/DD/YY)") If msg = vbNullString Or Not IsDate(msg) Then MsgBox "You Did Not Enter A Date!", vbCritical With Target ActiveWorkbook.Sheets("Report").Unprotect Password:="pass" .Value = "" .Font.Bold = False .Font.Underline = False .Offset(, 1).Select ActiveWorkbook.Sheets("Report").Protect Password:="pass", AllowFormattingCells:=True End With Else msg2 = MsgBox("You Entered A Close Date of " & msg _ & vbLf & vbLf & "Is This Tenitive?", vbYesNo + vbQuestion + vbDefaultButton2) NewDate = Format(CDate(msg), "MM/DD/YYYY") With Target ActiveWorkbook.Sheets("Report").Unprotect Password:="pass" .Value = NewDate .Font.Bold = (msg2 = vbNo) .Font.Underline = (msg2 = vbNo) .Offset(, 1).Select ActiveWorkbook.Sheets("Report").Protect Password:="pass", AllowFormattingCells:=True End With End If For Each c In ActiveSheet.Range("AF8:Af60") If IsDate(c.Value) And c.Font.Bold = True And c.Font.Underline = 2 And c.Value >= (Now - 9) Then c.Offset(, 4).Value = 1 Else ActiveWorkbook.Sheets("Report").Unprotect Password:="pass" c.Offset(, 4).Value = 0 ActiveWorkbook.Sheets("Report").Protect Password:="pass", AllowFormattingCells:=True End If Next c End If End Sub
the second one is
Code
Display MorePrivate Sub Worksheet_SelectionChange(ByVal Target As Range) Dim msgg As String Dim msgg2 As String Dim NewDate1 As Date Dim c1 As Range If Target.Cells.Count > 1 Then Exit Sub If Not Intersect(Target, Range("z8:z60")) Is Nothing Then msgg = InputBox("Please Enter A Date..." & vbLf & vbLf & "(MM/DD/YY)") If msgg = vbNullString Or Not IsDate(msg) Then MsgBox "You Did Not Enter Date!", vbCritical With Target ActiveWorkbook.Sheets("Report").Unprotect Password:="pass" .Value = "" .Font.Bold = False .Font.Underline = False .Offset(, 1).Select ActiveWorkbook.Sheets("Report").Protect Password:="pass", AllowFormattingCells:=True End With Else msgg2 = MsgBox("You Entered A Close Date of " & msg _ & vbLf & vbLf & "Is this compete?", vbYesNo + vbQuestion + vbDefaultButton2) NewDate1 = Format(CDate(msg), "MM/DD/YYYY") With Target ActiveWorkbook.Sheets("Report").Unprotect Password:="pass" .Value = NewDate1 .Font.Bold = (msgg2 = vbYes) .Font.Underline = (msgg2 = vbYes) .Offset(, 1).Select ActiveWorkbook.Sheets("Report").Protect Password:="pass", AllowFormattingCells:=True End With End If For Each c In ActiveSheet.Range("z8:z60") If IsDate(c1.Value) And c1.Font.Bold = True And c1.Font.Underline = 2 And c1.Value >= (Now - 9) And c1.Offset(, -23).Value = 4 Then c1.Offset(, 21).Value = 1 Else ActiveWorkbook.Sheets("Report").Unprotect Password:="pass" c1.Offset(, 21).Value = "0" ActiveWorkbook.Sheets("Report").Protect Password:="pass", AllowFormattingCells:=True End If Next c1 End If End Sub
-
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!