• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Call Macro when a cell changes doesn't works

cyapur

New Member
Hello world !

I have a problem here, this is the code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells = Range("Personal!C5") Then
    Call AjusteCeldas
    End If
End Sub

Sub AjusteCeldas()
' The macro code
End Sub

The problem is that it doesn't works when the cell C5 changes of value, but if I put "play" (deleting the Private Sub Code) Sub AjusteCeldas() works perfectly (but I have to put "play" each time that C5 changes of value..). The C5 cell is a list of names.

Regards !
 
Hi !

This is a very bad codeline : If Target.Cells = Range("Personal!C5") Then

Warming a couple of neurones : If Target.Address = "$C$5" Then

It always works with a right logic !
 
Hello cyapur

Welcome to the forum...Just for completeness...Here is the code.


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address= "$C$5" Then
    Call AjusteCeldas
    End If
End Sub

Sub AjusteCeldas()
' The macro code
End Sub

Please let me know if you have any further questions.
 
Back
Top