+ Reply to Thread
Results 1 to 8 of 8

Worksheet_SelectionChange Code in one Workbook for Selection in a Different Workbook

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Worksheet_SelectionChange Code in one Workbook for Selection in a Different Workbook

    Hi all.

    I am double-posting this question because I am in dire need of a solution. Here is the link to my other post: http://www.mrexcel.com/forum/showthr...41#post2819941

    I have a workbook that contains the following code used to select a sample from another workbook:

    Please Login or Register  to view this content.

    The code is in WorkbookA but the data to be selected is in WorksheetB.

    The code works fine when the data is and the code are in the same workbook but not when they are in different workbooks. It is not possible to have them in the same workbook.

    Can anyone help me get it working, please?

    Thank you,
    Gos-C
    Using Excel 2010 & Windows 10
    "It is better to be prepared for an opportunity and not have one than to have an opportunity and not be prepared."

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Worksheet_SelectionChange Code in one Workbook for Selection in a Different Workb

    Sample workbook?
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Worksheet_SelectionChange Code in one Workbook for Selection in a Different Workb

    Hi Tlafferty,

    Attached is a sample workbook containg the Worksheet_SelectionChange code. when you move the date to a different workbook the code should execute.

    Sorry, I had to make changes to keep it as generic as possible.

    Thanks,
    Gos-C
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Worksheet_SelectionChange Code in one Workbook for Selection in a Different Workb

    I'm gonna go out on a limb here and suggest moving your selection change code to the ThisWorkbook object, and use the Workbook deactivate event like this:
    Please Login or Register  to view this content.
    Let me know if there's any joy that way...

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Worksheet_SelectionChange Code in one Workbook for Selection in a Different Workb

    Do you mean cross posting? If so post the link to the other post!!!!!!!!!!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Worksheet_SelectionChange Code in one Workbook for Selection in a Different Workb

    Hi Tlafferty,

    I am not sure what you meant - I noticed that you have Private Sub Workbook_Deactivate() instead of Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    I moved the Worksheet_SelectionChange (with the added line If ActiveWorkbook.Name <> ThisWorkbook.Name Then to ThisWorkbook module but it didn't work.

    Help!

  7. #7
    Forum Contributor
    Join Date
    09-19-2004
    Location
    Canada
    Posts
    408

    Re: Worksheet_SelectionChange Code in one Workbook for Selection in a Different Workb

    Hi royUK,

    Yes, I meant cross posting. The link is in the first post.

    Gos-C

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Worksheet_SelectionChange Code in one Workbook for Selection in a Different Workb

    The link didn't show up at home, I'll check it when I get home.

    You can't run sheet or workbook event code to act on another workbooks sheet

+ 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