+ Reply to Thread
Results 1 to 9 of 9

VBA code to change info in one cell so that other cell changes, and vice versa

  1. #1
    Registered User
    Join Date
    06-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    6

    VBA code to change info in one cell so that other cell changes, and vice versa

    I'm new to this forum, so I apologize if this topic has been previously discussed. I'm trying to figure out how to insert text or a value into a cell in one worksheet so that it translates the same information to another cell in a separate one, and if I change info in that second cell, then it updates the original. I'm not really working with any formulas- I just need to be able to link one cell so that it reciprocally updates to another. I tried messing around with circular references but from what I've gathered, I think that I need to use a VBA code. Does anyone have any suggestions or examples of how I may be able to accomplish this? Thanks so much.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: VBA code to change info in one cell so that other cell changes, and vice versa

    You can accomplish this with the Worksheet_Change Event and the intersect function, but we need specifics.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    06-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: VBA code to change info in one cell so that other cell changes, and vice versa

    For example, if I type "yes" into A1 in one worksheet, I want to connect it to another cell in another worksheet, (say B6) so that it also says "yes". Inversely, if I type "no" in B6, I would like A1 to also update to "no". I'll also be doing the same with numbers, but I'm not sure if that matters. I have two similar worksheets that I'm working back and forth in, and linking cells so that one is dependent on the other is proving to be a bit time-consuming. Thanks David!

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: VBA code to change info in one cell so that other cell changes, and vice versa

    In the Sheet1 code module.
    Please Login or Register  to view this content.
    In the Sheet2 code
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: VBA code to change info in one cell so that other cell changes, and vice versa

    Thank you so much! That worked perfectly. If I want to do that for multiple cells (say connect A2 to B7, A3 to B8, etc.), do I need to create a separate code for each pair? I tried it by copying and pasting one beneath the other and then modifying the references accordingly and it worked, but I'm just making sure I'm not over-looking something that would be much quicker.

  6. #6
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: VBA code to change info in one cell so that other cell changes, and vice versa

    You might could write more sophisticated/compact code, but as long as you understand it, and it works, let 'er go!

  7. #7
    Registered User
    Join Date
    06-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: VBA code to change info in one cell so that other cell changes, and vice versa

    Ok, cool. Thanks again, I really appreciate your help!!

  8. #8
    Registered User
    Join Date
    09-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    13

    Re: VBA code to change info in one cell so that other cell changes, and vice versa

    Hi Tarab,

    I tried this code, and it appears to be creating an infinite loop.

    So when A1 changes B6 on the other sheet, the Worksheet Change executes again, and again. Is there a way to prevent this from looping?

    Thanks!

  9. #9
    Registered User
    Join Date
    09-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    13

    Re: VBA code to change info in one cell so that other cell changes, and vice versa

    Nevermind, I wrapped the code with Application.EnableEvents = False & then True before End If.

    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