Results 1 to 9 of 9

Thread: Get Return Value Of Active Cell On Change Of Selection Change

  1. #1
    Member
    Join Date
    Jun 2012
    Posts
    39
    Rep Power
    0

    Get Return Value Of Active Cell On Change Of Selection Change

    I was wondering if there is any possibility of a macro, which returns to a particular cell, the content of the active cell.
    And the active cell can be any where in the same workbook except the cell in which the result is shown.
    Like,

    A1 is the cell where I need the content of the active cell. and this active cell can be any where except A1

    Regards,
    Safal

  2. #2
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Install the following Event macro in the worksheet code area:

    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Range("A1").Value = ActiveCell.Text
    End Sub

    Because it is worksheet code, it is very easy to install and automatic to use:

    1. right-click the tab name near the bottom of the Excel window
    2. select View Code - this brings up a VBE window
    3. paste the stuff in and close the VBE window

    If you have any concerns, first try it on a trial worksheet.

    If you save the workbook, the macro will be saved with it.
    If you are using a version of Excel later then 2003, you must save
    the file as .xlsm rather than .xlsx

    To remove the macro:

    1. bring up the VBE windows as above
    2. clear the code out
    3. close the VBE window

    To learn more about macros in general, see:

    Getting Started with Macros and User Defined Functions

    To learn more about Event Macros (worksheet code), see:

    Event Macros, Worksheet Events and Workbook Events

    Macros must be enabled for this to work!

  3. #3
    Member
    Join Date
    Jun 2012
    Posts
    39
    Rep Power
    0
    Thanx. It works great.

  4. #4
    Member
    Join Date
    Jun 2012
    Posts
    39
    Rep Power
    0
    It is working fine with the single sheet but how can i make it work in the entire workbook? Can I do make it work in every open workbook?

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    You would need to replicate the code on every sheet of every open workbook.

  6. #6
    Member
    Join Date
    Jun 2012
    Posts
    39
    Rep Power
    0
    Do I have to do it for different sheets in the same workbook?

  7. #7
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    I believe that is correct.

  8. #8
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14
    You can try this and no need to replicate the code just follow the steps:

    1. Open excel
    2. Press Alt + F11
    3. In the right side you can see Project explore if not press Ctrl + R
    4. Double click on ThisWorkbook
    5. Paste below code

    Code:
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
        Range("a1").Value = ActiveCell.Value
    End Sub

  9. #9
    Member
    Join Date
    Jun 2012
    Posts
    39
    Rep Power
    0
    Thanks. Also I used the sheet name so that I can get the desired result, whereever the active cell is cell A1 of sheet1 will show the content.

Similar Threads

  1. Replies: 1
    Last Post: 05-03-2013, 04:41 PM
  2. Change Display Range Based On Change of Dropdown Values
    By rich_cirillo in forum Excel Help
    Replies: 2
    Last Post: 03-29-2013, 04:58 AM
  3. Worksheet Change Event
    By jamilm in forum Excel Help
    Replies: 2
    Last Post: 12-29-2012, 12:06 AM
  4. Change listbox value
    By Tony in forum Excel Help
    Replies: 4
    Last Post: 12-04-2012, 08:58 PM
  5. Replies: 1
    Last Post: 08-21-2012, 07:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •