+ Reply to Thread
Results 1 to 11 of 11

Referencing Active Cell's Value from Another Sheet

  1. #1
    Registered User
    Join Date
    10-23-2008
    Location
    US
    Posts
    26

    Referencing Active Cell's Value from Another Sheet

    Hi - I'd like for users to click in a cell in col A in a sheet named "Period7", have the cell value placed in cell C11 in a sheet named "Per7Report," and change the focus or active sheet to sheet Per7Report.

    Can this be done simply by clicking in a cell, or must a command button be inserted into each cell (note - odd rows only) in col A in Period7.

    Any help on the code to do this would be greatly appreciated.

    Note that there is a formula in col A in sheet Period7

    Thanks
    Last edited by VBA Noob; 10-23-2008 at 05:19 PM.

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Right-click on the Period7 sheet tab, select view code, and copy this code:

    Please Login or Register  to view this content.
    This will run by either clicking on an odd cell in column A, or moving the cursor there with the arrow keys.

    HTH

    Jason

  3. #3
    Registered User
    Join Date
    10-23-2008
    Location
    US
    Posts
    26
    Hi Jason,

    Thanks, but your code is not firing. There was already a worksheet change event...

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    The SelectionChange event is different than the Change event. The Change event is triggered when the range you set is "changed". The SelectionChange event is triggered when you "select" the range.

    In your original post when you say "click in a cell in col A", do you simply mean select a cell in col A?

  5. #5
    Registered User
    Join Date
    10-23-2008
    Location
    US
    Posts
    26
    Yes, I tried the code block as is and it did not appear to work.

    Col A contains a formula that combines students' last and first names, in cols B and C. Then, this col A value is what I'm using in a VLOOKUP in the report sheet.

    It would be great if a teacher could simply click on any odd cell in col A, causing the value in that active cell to be put into the C11 cell in the report sheet.

    Thanks again.

  6. #6
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Well, the code I posted above works exactly how you are describing. I'm not sure why it is not working on your end.

    Try this:

    -Go to the VBE (ALT + F11)
    -Go to the Immediate Window (CTRL + g)
    -Type Application.EnableEvents=True and hit Enter

    Try selecting an odd row in column A again, and see if it works.

  7. #7
    Registered User
    Join Date
    10-23-2008
    Location
    US
    Posts
    26
    How cool is that?! It works after doing what you indicated. Must this application events be enabled/disabled in the code, or should it be fine? Thanks.

  8. #8
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Based on the way it is written, it should be fine. What probably happened is at one point, the code must have broke before enabling events again.

  9. #9
    Registered User
    Join Date
    10-23-2008
    Location
    US
    Posts
    26
    Thanks again JasonCW

  10. #10
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    No problem.

  11. #11
    Registered User
    Join Date
    07-14-2012
    Location
    Haryana, India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Referencing Active Cell's Value from Another Sheet

    HI Jason,

    Using same code.

    its working for odd numbered rows not for even numbered.

    Also since do not want to activate the sheet in which value is copied I've deleted .Activate from last line of code

+ 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