Worksheet change not firing

RockEd

New Member
Joined
Aug 13, 2021
Messages
40
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

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

rlv01

Well-known Member
Joined
May 16, 2017
Messages
1,174
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 

RockEd

New Member
Joined
Aug 13, 2021
Messages
40
Office Version
  1. 365
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
67,826
Office Version
  1. 365
Platform
  1. Windows
How are the values in C4:C27 being changed?
 

RockEd

New Member
Joined
Aug 13, 2021
Messages
40
Office Version
  1. 365
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
67,826
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Manually by myself
That's fine, where is the code located? is it in a sheet module?
 
Solution

RockEd

New Member
Joined
Aug 13, 2021
Messages
40
Office Version
  1. 365
Platform
  1. Windows
That's fine, where is the code located? is it in a sheet module?
Ah that's the issue!! No, it's in a (standard?) module.

Okay so firing fixed...! Thank you!
 

RockEd

New Member
Joined
Aug 13, 2021
Messages
40
Office Version
  1. 365
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
67,826
Office Version
  1. 365
Platform
  1. Windows
Glad you sorted it & thanks for the feedback.
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,589
Messages
5,765,314
Members
425,272
Latest member
Umba

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
Top