Change by value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a this code.
the problem is when the "Card Entered" part is also a value change...so it
just keeps repeating. is there a way to make it so if value = "Card Entered"
the code does not run

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("fa7").Address Then
Range("fc7").Value = Range("fa7").Value
Range("fa7") = "Card Entered"
End If
End Sub

ThaNKS in advance
 
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error Goot ws_exit:
If Target.Address = Range("fa7").Address Then
Range("fc7").Value = Range("fa7").Value
Range("fa7") = "Card Entered"
End If

ws_exit:
Application.EnableEvents = True
End Sub
 
Any thime you are using the on change event you have to be careful about
having the procedure call itself recursivly. This occures if you change a
value within the procedure which causes the procedure to fire again. To avoid
this you need to add

application.enableevents = false

at the beginning of the code and

application.enableevents = true

at the end of the code... Be careful to always turn the events back on
again...

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top