+ Reply to Thread
Results 1 to 4 of 4

Retrieve individual cells from a range changed between a range

  1. #1
    Registered User
    Join Date
    07-28-2005
    Posts
    15

    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")?
    Last edited by baldomero; 09-04-2005 at 05:48 PM.

  2. #2
    Norman Jones
    Guest

    Re: 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" <[email protected]> wrote
    in message news:[email protected]...
    >
    > 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
    >




  3. #3
    Registered User
    Join Date
    07-28-2005
    Posts
    15
    Ok, thanks, it seems good for me, I'll try to implement with that, thanks!

  4. #4
    Registered User
    Join Date
    07-28-2005
    Posts
    15
    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!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1