Worksheet_Change

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

Guest

Using

Private Sub Worksheet_Change(ByVal Target As Range)

How do you select a perticular range like b5 - b15

found for a single cell but not a range
 
I'm a newbie but, I used this for one of my worksheet change events. If
you have it set for a single cell. Target = Range("B5"), could you not
just use Range("B5:B15") ?

Dim myrow&, myCol&
myrow = Target.Row
myCol = Target.Column

If myrow > 0 And myrow < 100 Then
If myCol > 0 And myCol < 100 Then
 
If Not Intersect(Target,Range("B5:B15)) Is Nothing Then
'it is one of B5:B15


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Private Sub Worksheet_Change(ByVal Target As Range)
if Union(Target,Range("B5:B15")).Address = "$B$5:$B$15" then


end if
End Sub

if you want to react to only a change in a single cell in the Range B5:B15

Private Sub Worksheet_Change(ByVal Target As Range)
if Target.count > 1 then exit sub
if Not Intersect(Target,Range("B5:B15")) is nothing then


end if
End Sub
 
Thanks for looking, got it:

Set myRange = Intersect(Range("b5:b15"), Target)
If Not myRange Is Nothing Then
' your code
End If

Cheers
 
Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A2:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Value = Target.Value * 0.3
Application.EnableEvents = True
End Sub

This looks for changes in a certain range
 

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