![]() |
cell change event
I'm having trouble making a subroutine run upon a change to the value in cell
B2. This is the code: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "B2" Then Dim Blank_count As Integer etc etc End If End Sub I'm sure I'm missing something obvious, thank you in anticipation! ... Greg |
Use absolute reference:
If Target.Address = "$B$2" Then Stefi gvm ezt *rta: I'm having trouble making a subroutine run upon a change to the value in cell B2. This is the code: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "B2" Then Dim Blank_count As Integer etc etc End If End Sub I'm sure I'm missing something obvious, thank you in anticipation! ... Greg |
Thanks Stefi, I was so close!
A supplementary question if I may: in an attempt to avoid the inflexibility of using an absolute address, I experimented with referring to a defined name instead but I could not make it work, ie I tried both Target.Address = "cars" and Target.Address = cars and neither worked. Is there an alternative to the absolute address method? TIA ... Greg |
One way:
Dim overlap As Range Set overlap = Intersect(Target, Range("Cars")) If Not overlap Is Nothing Then Dim blank_count As Integer 'etc 'etc End If gvm wrote: Thanks Stefi, I was so close! A supplementary question if I may: in an attempt to avoid the inflexibility of using an absolute address, I experimented with referring to a defined name instead but I could not make it work, ie I tried both Target.Address = "cars" and Target.Address = cars and neither worked. Is there an alternative to the absolute address method? TIA ... Greg |
All times are GMT +1. The time now is 02:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com