+ Reply to Thread
Results 1 to 4 of 4

Sync two cells in the same workbook - but in different worksheets

Hybrid View

  1. #1
    Registered User
    Join Date
    11-07-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 2016
    Posts
    6

    Sync two cells in the same workbook - but in different worksheets

    Referencing an old 2009 thread - Syncing two cells in different worksheets by skyrave in 2009.

    I must be missing a little piece of code or have a something listed wrong.
    Please help.

    =================
    This Works ..... The data updates in A1 as I am typing it in A2.
    ==================
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim rCell1 As Range
    Dim rCell2 As Range
    If Target.Count > 1 Then Exit Sub
    On Error GoTo err_handler
    Set rCell1 = Sheets("A").Range("A1")
    Set rCell2 = Sheets("B").Range("A2")
    Application.EnableEvents = False
    Select Case ActiveSheet.Name
    Case "A": If Target.Address = rCell1.Address Then rCell2.Value = rCell1.Value
    Case "B": If Target.Address = rCell2.Address Then rCell1.Value = rCell2.Value
    End Select
    err_handler:
    Application.EnableEvents = True
    End Sub
    ========================
    This does NOT work .....
    The only difference between these two code snippets are:
    - the two 'Sheets' references. Above its "A" and "B" and Below, its "Cockpit" and "Enroute Flt Mgt" and
    - Cell references above are "A1" & "A2" and below its "B11" and "E9"
    ========================
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim rCell1 As Range
    Dim rCell2 As Range
    If Target.Count > 1 Then Exit Sub
    On Error GoTo err_handler
    Set rCell1 = Sheets("Cockpit").Range("B11")
    Set rCell2 = Sheets("Enroute Flt Mgt").Range("E9")
    
    Application.EnableEvents = False
    Select Case ActiveSheet.Name
    Case "A": If Target.Address = rCell1.Address Then rCell2.Value = rCell1.Value
    Case "B": If Target.Address = rCell2.Address Then rCell1.Value = rCell2.Value
    End Select
    err_handler:
    Application.EnableEvents = True
    
    End Sub
    ===================
    It's gotta be something simple I am just not seeing. please help
    Last edited by Leith Ross; 11-09-2015 at 10:48 PM. Reason: Added Code Tags

  2. #2
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Sync two cells in the same workbook - but in different worksheets

    in your second SheetChange event your select case has "A" and "B" instead of "Cockpit" and "Enroute Flt Mgt"

    Change
    Case "A": If Target.Address = rCell1.Address Then rCell2.Value = rCell1.Value
    Case "B": If Target.Address = rCell2.Address Then rCell1.Value = rCell2.Value
    To
    Case "Cockpit": If Target.Address = rCell1.Address Then rCell2.Value = rCell1.Value
    Case "Enroute Flt Mgt": If Target.Address = rCell2.Address Then rCell1.Value = rCell2.Value
    Last edited by mongoose36; 11-09-2015 at 10:55 PM.
    If your questions has been answered to your satisfaction please don't forget to do the following:

    Add Reputation ... and ... Mark Thread as Solved

    Thanks,

    Ma 10:8b Freely you have received; freely give.

  3. #3
    Registered User
    Join Date
    11-07-2015
    Location
    Tennessee
    MS-Off Ver
    MS Office 2016
    Posts
    6

    Re: Sync two cells in the same workbook - but in different worksheets

    Awesome, thank you!

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Sync two cells in the same workbook - but in different worksheets

    replace the A and B in the following codes with your sheets names
    Case "A": If Target.Address = rCell1.Address Then rCell2.Value = rCell1.Value
    Case "B": If Target.Address = rCell2.Address Then rCell1.Value = rCell2.Value
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-05-2015, 08:45 PM
  2. [SOLVED] Copy Specific Cells Across all worksheets in a Workbook and Paste Into single New Workbook
    By thunt13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2013, 10:43 AM
  3. Replies: 0
    Last Post: 02-09-2012, 08:17 AM
  4. Sync formulas between worksheets in same file
    By aamir in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2010, 06:34 AM
  5. keep two cells in a excel in sync by cross linking
    By srinu1264 in forum Excel General
    Replies: 6
    Last Post: 12-23-2009, 03:46 PM
  6. Cross Link/Sync cells where you can change either
    By nature47 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2009, 09:58 PM
  7. How to keep two cells in a excel in sync by cross linking
    By sibbe7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2009, 12:47 PM

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