ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet_Change (https://www.excelbanter.com/excel-programming/345753-worksheet_change.html)

dan

Worksheet_Change
 
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

Kevin O'Neill[_2_]

Worksheet_Change
 
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


Bob Phillips[_6_]

Worksheet_Change
 

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)


"Dan" wrote in message
...
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




Tom Ogilvy

Worksheet_Change
 
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


--
Regards,
Tom Ogilvy

"Dan" wrote in message
...
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




dan

Worksheet_Change
 
Thanks for looking, got it:

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

Cheers


"Dan" wrote:

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


Gary''s Student

Worksheet_Change
 
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
--
Gary's Student


"Dan" wrote:

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



All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com