+ Reply to Thread
Results 1 to 5 of 5

How do I embed a macro in a cell so it filters the data on another sheet?

Hybrid View

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    sacramento
    MS-Off Ver
    Excel 2007
    Posts
    3

    How do I embed a macro in a cell so it filters the data on another sheet?

    I have a workbook with 2 spreadsheets: Summary and (raw Data)

    Summary is a cross tabbed table basically.

    soexcel question.png
    Self-Assessed Agency-Assessed
    1 day 15 (B2) 13
    2 days 26 56
    3 days 14 16 (C4)
    4 days 89 58

    When I click on cell B2 of the Summary sheet, I would like the screen to jump to the (raw data) sheet, and set the filter to "1 day" and "Self-assessed". Likewise, if i were to click on cell C4, I would like the screen to jump to the (raw data) sheet, and set the filter to "3 days" and "Agency-assessed".

    Can someone tell me the macro and explain it to me so I can apply it to my whole summary sheet?

    I appreciate any and all help.
    Last edited by aia8998; 10-09-2013 at 01:54 PM. Reason: updated image of spreadsheet since spacing was not showing correctly in thread

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I embed a macro in a cell so it filters the data on another sheet?

    Hi,

    You can capture the cell selection event by using the WorkSheet_SelectionChange event.
    So right click on the tab name to open up this event procedure - it happens to be the default procedure for sheet events.

    In there add code like

    If Not Intersect(Target, Range("B2")) Is Nothing Then
       Sheet2.Activate
       Range("MyFilterCell") = "1 day"
    End If
    which assumes that your Raw Data sheet has the VBA codename Sheet2
    But just change this as necessary.

    You could substitute
    Sheets("Raw Data").Activate

    but it's generally not good practice to code with sheet tab names since users can easily change them. Code is more robust when you use the VBA sheet code name.
    Last edited by Richard Buttrey; 10-09-2013 at 01:58 PM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    10-23-2012
    Location
    sacramento
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How do I embed a macro in a cell so it filters the data on another sheet?

    Thank you so much for the prompt reply!

    Nothing is happening so I must be missing something. I am not that skilled in VB so please forgive me.

    I right clicked on the tab name on the bottom, and pasted in the code. I am not sure where I should be looking to confirm that the WorkSheet_SelectionChange event is activiated. Where do I confirm that?

  4. #4
    Registered User
    Join Date
    10-23-2012
    Location
    sacramento
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How do I embed a macro in a cell so it filters the data on another sheet?

    I got it to work with some tinkering around. Thank you very much!

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: How do I embed a macro in a cell so it filters the data on another sheet?

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 08-06-2013, 02:47 AM
  2. Excel 2007 : Copying data filters from one sheet to another?
    By rsidheshkumar in forum Excel General
    Replies: 1
    Last Post: 05-02-2010, 03:15 AM
  3. Replies: 2
    Last Post: 01-30-2007, 09:58 AM
  4. [SOLVED] Getting Data from Embed combo box in excel sheet to vb .net
    By CoolCyber in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2005, 07:05 PM
  5. [SOLVED] how to embed objects from other applications in 1 cell in excel sheet
    By helpwithXL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2005, 07:06 AM

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