View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
mastermind mastermind is offline
external usenet poster
 
Posts: 36
Default Change Event Problem

For some reason the change event will only run once. I don't know what
would cause that to happen, but that is what it is doing. Do you know
of anything that would cause that, or perhaps how to correct that
problem? The full section of code I now have is:

Private Sub Worksheet_Change(ByVal Target As Range)
Const sAdd1 As String = "AQ3"
Const sAdd2 As String = "AP6"
Const sAdd3 As String = "AP8"

If Not Intersect(Range(sAdd1), Target) Is Nothing Then
If Target.Value < "" Then
Application.EnableEvents = False
ActiveSheet.Name = "Report " & Range(sAdd1).Value
End If
End If

If Not Intersect(Range(sAdd2), Target) Is Nothing Then
If Target.Value < "" Then
Application.EnableEvents = False

'Determines number of days between two dates
NumDays = Range(sAdd2).Value - Range("$BA$12").Value

'Performs a sort of modulus
Do While NumDays 7
NumDays = NumDays - 7
Loop

ActiveSheet.Unprotect

' Determines weekday
If NumDays = 1 Then
Range(sAdd3).Value = "Monday"
ElseIf NumDays = 2 Then
Range(sAdd3).Value = "Tuesday"
ElseIf NumDays = 3 Then
Range(sAdd3).Value = "Wednesday"
ElseIf NumDays = 4 Then
Range(sAdd3).Value = "Thursday"
ElseIf NumDays = 5 Then
Range(sAdd3).Value = "Friday"
ElseIf NumDays = 6 Then
Range(sAdd3).Value = "Saturday"
Else
Range(sAdd3).Value = "Sunday"
End If

ActiveSheet.Protect
End If
End If
End Sub


If you have any ideas for simplifying the code please let me know.

John