![]() |
Change by value
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 |
Change by value
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 -- HTH Bob Phillips "choice" wrote in message ... 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 |
Change by value
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 "choice" wrote: 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 |
All times are GMT +1. The time now is 12:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com