Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
gvm
 
Posts: n/a
Default 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
  #2   Report Post  
Stefi
 
Posts: n/a
Default

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

  #3   Report Post  
gvm
 
Posts: n/a
Default

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

  #4   Report Post  
Rowan
 
Posts: n/a
Default

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
change info in 1 cell, prompts you for another redb Excel Discussion (Misc queries) 2 September 1st 05 11:56 AM
cell value change event alinasir Excel Worksheet Functions 1 August 30th 05 10:57 AM
Change cell color dependin on date ... T. Denford Excel Worksheet Functions 4 April 13th 05 01:59 AM
How do I change color of active cell in Excel lfletcher Excel Discussion (Misc queries) 4 April 4th 05 06:29 PM
Worksheet Row Change event crazybass2 Excel Discussion (Misc queries) 4 December 8th 04 05:29 PM


All times are GMT +1. The time now is 09:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"