ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Retrieve individual cells from a range changed between a range (https://www.excelbanter.com/excel-programming/339169-retrieve-individual-cells-range-changed-between-range.html)

baldomero[_4_]

Retrieve individual cells from a range changed between a range
 

Hi. What I would like to do is retrieve the cells, using the
Worksheet_Change Event.

The question is that I only want to retrieve those cells that are from
a determined range I want to work(B1:E5 for example)

I do a:

*For Each Range In Range(Target.Address)*, the problem is that this
returns every cell changed on the Worksheet, but I don't know how to
determine if the cells are on the B1:E5 range. Any help?

EDIT:: In other words, what I need to do is something like:

Is this single cell part of this range?
Is Cells(3, 3) into Range("B1:B5")?


--
baldomero
------------------------------------------------------------------------
baldomero's Profile: http://www.excelforum.com/member.php...o&userid=25680
View this thread: http://www.excelforum.com/showthread...hreadid=401820


Norman Jones

Retrieve individual cells from a range changed between a range
 
Hi Baldomero,

Try something like:

'========================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range

Set rng = Range("B1:B5")

If Not Intersect(Target, rng) Is Nothing Then
'Do something, e.g.:
MsgBox Target.Address
Else
'Do nothing
End If

End Sub
'<<========================

---
Regards,
Norman



"baldomero" wrote
in message ...

Hi. What I would like to do is retrieve the cells, using the
Worksheet_Change Event.

The question is that I only want to retrieve those cells that are from
a determined range I want to work(B1:E5 for example)

I do a:

*For Each Range In Range(Target.Address)*, the problem is that this
returns every cell changed on the Worksheet, but I don't know how to
determine if the cells are on the B1:E5 range. Any help?

EDIT:: In other words, what I need to do is something like:

Is this single cell part of this range?
Is Cells(3, 3) into Range("B1:B5")?


--
baldomero
------------------------------------------------------------------------
baldomero's Profile:
http://www.excelforum.com/member.php...o&userid=25680
View this thread: http://www.excelforum.com/showthread...hreadid=401820




baldomero[_5_]

Retrieve individual cells from a range changed between a range
 

Ok, thanks, it seems good for me, I'll try to implement with that,
thanks!


--
baldomero
------------------------------------------------------------------------
baldomero's Profile: http://www.excelforum.com/member.php...o&userid=25680
View this thread: http://www.excelforum.com/showthread...hreadid=401820


baldomero[_6_]

Retrieve individual cells from a range changed between a range
 

This is exactly what I was looking for:



--------------------------------------------------------------------------
Dim Rang2 As Range
Dim rang As Range
Set rang = Range("B1:D15")

If Not Intersect(Target, rang) Is Nothing Then

For Each Rang2 In Target

If Not Intersect(rang, Rang2) Is Nothing Then
MsgBox (Rang2.Address)
End If

Next
End If
--------------------------------------------------------------------------

I could not have done this code without your help, thanks

--
baldomer
-----------------------------------------------------------------------
baldomero's Profile: http://www.excelforum.com/member.php...fo&userid=2568
View this thread: http://www.excelforum.com/showthread.php?threadid=40182



All times are GMT +1. The time now is 06:50 PM.

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