+ Reply to Thread
Results 1 to 7 of 7

If cell active then change value in another cell

  1. #1
    Registered User
    Join Date
    08-12-2004
    Location
    Mendoza, Argentina
    MS-Off Ver
    Office Professional 2003
    Posts
    89

    If cell active then change value in another cell

    Please Login or Register  to view this content.
    The value of cell L49 =1, L50=2 and L51 =3

    Depending what number is in cell P50, affects the balance of a column of figures Column Q.
    Up to now, I have been changing the number (1,2,3) in P50 to reflect what I want as this works with an If formula in Q50.
    However, If I could just click in one of the cells in Col L that would change value of the cell P50, I would not have to change manually.

    Any thoughts on where I am wrong in the above code.

    Many thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,126

    Re: If cell active then change value in another cell

    thadacto,

    I thought I had a solution, but then realized I don't understand the problem. Are you wanting to:
    1) Activate the sheet (coming from another sheet)
    2) See what cell has been activated (not what cell you activate, but the last cell clicked on that sheet before you reactivated it)
    3) Depending on that, change the values in P50?

    Or, are you wanting to:
    1) Activate (select) a cell on the active sheet
    2) Depending on that selection, change the values in P50?


    If the second one is right, I think you;d need to use a Worksheet change event:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-12-2004
    Location
    Mendoza, Argentina
    MS-Off Ver
    Office Professional 2003
    Posts
    89

    Re: If cell active then change value in another cell

    Thanks for the reply, jomili.

    Yes, it is your second suggestion. Only dealing with Sheet2.
    When I select (by clicking in it with the mouse) Cell L49, I want P50 to change to a value of 1
    When I select cell L50, I want the value in P50 to be 2
    When I select cell L51, I want the value in P50 to be 3 .... and so on.

    When any other cell on the sheet is selected it has no effect on P50 (which obviously it won't because it is not in the code to do something!

    Hope this is clearer.
    Last edited by thadacto; 03-28-2013 at 03:09 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,126

    Re: If cell active then change value in another cell

    here's the basic code you need:
    Please Login or Register  to view this content.
    You'd paste this into a sheet module, not a standard module (ie in the VBA editor double-click on the sheet tab you want to use this in). You'd also need to add your various "ElseIF" statements for any other actions.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If cell active then change value in another cell

    Maybe:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-12-2004
    Location
    Mendoza, Argentina
    MS-Off Ver
    Office Professional 2003
    Posts
    89

    Re: If cell active then change value in another cell

    Many thanks for all the help, jomili and JOHN H.

    jomili, I didn't get your code to work but I'll get back to it and see if I can.

    JOHN H. Your piece of code worked great, and even allows for going much further down the "L" column.
    Many thanks indeed.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If cell active then change value in another cell

    You're welcome. Glad to help out, and thanks for the feedback.

+ 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