+ Reply to Thread
Results 1 to 2 of 2

mirror ranges of cell between worksheets

  1. #1
    Registered User
    Join Date
    08-27-2009
    Location
    US
    MS-Off Ver
    Excel 200
    Posts
    1

    mirror ranges of cell between worksheets

    While I'm a vba newbie, I try (and I hope I'm posting in the right place)...

    I'm trying to mirror a range of cells on Sheet1 to Sheet 2. I found the following code elsewhere in the forums (credit to davesexcel):

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Union(Range("$F$13:$F$16"), Target).Address = Range("$F$13:$F$16").Address Then
    Target.Offset(0, 4) = Target
    End If
    If Union(Range("$J$13:$J$16"), Target).Address = Range("$J$13:$J$16").Address Then
    Target.Offset(0, -4) = Target
    End If

    End Sub

    OK - so I modified it to this:

    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim myRange As Range
    Dim myRange2 As Range

    Set myRange = Worksheets("Sheet1").Range("$F$13:$F$16")
    Set myRanges = Worksheets("Sheet2").Range("$J$13:$J$16")

    If Union(myRange, Target).Address = myRange.Address Then
    Target.Offset(0, 4) = Target
    End If
    55 If Union(myRanges, Target).Address = myRanges.Address Then
    Target.Offset(0, -4) = Target
    End If

    End Sub

    Yes, I probably mangled it badly as I don't exactly understand the statement. I'm hoping someone could post something that does work and I can compare/understand...? it does work if I change Sheets2 to Sheets1...

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: mirror ranges of cell between worksheets

    Welcome to the forum.

    Plewase take a few minutes to read the forum rules, and then edit your post to add code tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

+ 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