Results 1 to 6 of 6

Intersect, Target, Range - referencing from another cell, a problem....

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-26-2008
    Location
    UK
    MS-Off Ver
    Using Excel 2019
    Posts
    317

    Intersect, Target, Range - referencing from another cell, a problem....

    Hi,

    I have this private sub on a worksheet.


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    If Not Intersect(Target, Range("C5:C1000")) Is Nothing Then
    
        Worksheets("Sheet1").Unprotect
        Target.Copy Destination:=Sheets("Sheet1").Range("U2")
            Worksheets("Sheet1").Visible = True
            Sheets("Sheet1").Select
            Worksheets("Sheet1").Protect
    End If
    
    End Sub
    This works fine, copying the value of the cell selected in column C, and pasting it to the range U2 on 'Sheet1'.

    However, I've now referenced the value of C5:C1000 from cells D5:D1000. So C5=D5, C6=D6 etc... This is causing the above code to not quite work. When i then click on a cell it copies the value of "V2" on Sheet1 into cell "U2" on Sheet1. I realize this is something to do with the fact that Im now referencing another cell (one across from the original), but i cant quite work out how to fix it.

    Any ideas?


    ps: I have to reference the cells, as another macro on another sheet copies and pastes information into the sheet with the code (ie into C5:C1000) As a result this automatically triggers the private sub - which i don't want it to do. So referencing it means the private sub doesn't get triggered when the other macro runs.
    Last edited by Barking_Mad; 02-17-2014 at 09:19 AM. Reason: corrected code.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Multiple Target Intersect Ranges on Same Worksheet
    By Mistweaver in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-28-2013, 04:35 PM
  2. Replies: 2
    Last Post: 01-29-2013, 09:38 AM
  3. Problem with Intersect(Target)
    By fcarboni in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2012, 09:02 AM
  4. Worksheet_CHange (ByVal Target as Range) when target is formula cell
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2012, 07:00 PM
  5. referencing rows using variable and Intersect range
    By tryer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2009, 02:19 PM

Tags for this Thread

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