+ Reply to Thread
Results 1 to 6 of 6

Macros to change a cell value by clicking and to take you to another sheet

  1. #1
    Forum Contributor
    Join Date
    09-21-2007
    Posts
    196

    Macros to change a cell value by clicking and to take you to another sheet

    Hi,

    I need to create two very simple macros and hoped that somebody might be able to help.

    The first one needs to change the value in one specified cell to the value in another range of cells when one of them is clicked on.

    e.g. if Cell B2 is the specified Cell and the range of cells is A1 to A100. When you click on Cell A2 the value in cell B2 changes to the value in A2.

    The second is just that when you click on a cell in a range of cells it takes to one specific chart or worksheet. So if the range was A1 to A100 and you clicked on any of those cells you would be taken to a sheet called template.

    Many thanks and any help on either issue greatfully received.

    Jack

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macros to change a cell value by clicking and to take you to another sheet

    The Worksheet_SelectionChange event macro can do both of these for you.

    Since you specified BOTH actions occur when the same range of cells is clicked then this event would update the value in B2 and then take you to the "Template" sheet automatically.

    1) Right-click the sheet tab and select View Code to open the sheet module
    2) Paste in this event macro:
    Please Login or Register  to view this content.

    If you don't like the "selection" method, you could replace it with a "double click" event, you would have to double click a cell in the range A1:A100 to get this event to trigger:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 11-09-2011 at 09:39 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    09-21-2007
    Posts
    196

    Re: Macros to change a cell value by clicking and to take you to another sheet

    That is excellent, the only very minor change I would like is can the cell that is changed not be B2 but A1 on the template sheet?

    Many thanks

    Jack

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,384

    Re: Macros to change a cell value by clicking and to take you to another sheet

    Hi Jack,

    Here is the code and the attachment to do what you want.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macros to change a cell value by clicking and to take you to another sheet

    YOu don't need to actually "GO" to the template page to put a value into it. Using the "doubleclick" method, still:

    Please Login or Register  to view this content.

    You can remove the underlined code if you want to stay on your original sheet.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macros to change a cell value by clicking and to take you to another sheet

    @Marvin, be careful where/if you put in the Cancel = True code, in your suggested spot it would effectively disable doubleclick access to any cell on the entire sheet. Place it inside your IF results to only disable it when the doubleclick occurred inside one of the watched ranges.

+ 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