Worksheet change not firing

RockEd

Board Regular
Joined
Aug 13, 2021
Messages
80
Office Version
  1. 365
Platform
  1. Windows
I'm building up some code on the back of a worksheet change event. But I cannot see where I am going wrong:

If any of the cell values C4 through to C27 are changed to "Done" then I would like to apply a value to the respective row in column J:

e.g.

cell C4 = Done
Change J4 to Now()

I'm a little unsure how to do that second part?

However I can't even do a basic change event in the first place!! Can anyone help with both problems (firing the event change code, and then putting a basic value in another cell)?

Thank you in advance.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C4:C27")) Is Nothing Then

    If Target.Value = "Done" Then Debug.Print "Hello"
    
        End If
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
The first thing to do is to make sure events have not been disabled.

VBA Code:
Sub CheckEvents()
    If Application.EnableEvents Then
        MsgBox "Events are enabled"
    Else
        Select Case MsgBox("Events are disabled. " & vbCr & vbCr & "Re-enable?", vbYesNo Or vbQuestion, Application.Name)
        Case vbYes
            Application.EnableEvents = True
        End Select
    End If
End Sub
 
Upvote 0
Thanks ...events are enabled though and still nothing.
The first thing to do is to make sure events have not been disabled.

VBA Code:
Sub CheckEvents()
    If Application.EnableEvents Then
        MsgBox "Events are enabled"
    Else
        Select Case MsgBox("Events are disabled. " & vbCr & vbCr & "Re-enable?", vbYesNo Or vbQuestion, Application.Name)
        Case vbYes
            Application.EnableEvents = True
        End Select
    End If
End Sub
 
Upvote 0
How are the values in C4:C27 being changed?
 
Upvote 0
Perhaps there is something wrong with my Excel; even basic change events code like this is doing nothing:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$1" Then

     MsgBox "This Code Runs When Cell A1 Changes!"

End If

End Sub
 
Upvote 0
Okay so I came up with this in the end...

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C4:C27")) Is Nothing Then

    If Target.Value = "Done" Then

With Target
    .Offset(0, 7).Value = Now()
    
End With
    
    End If
End If
    
End Sub
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,225
Members
448,951
Latest member
jennlynn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top