+ Reply to Thread
Results 1 to 15 of 15

Clicking a cell should trigger a MsgBox with specific details

  1. #1
    Registered User
    Join Date
    11-04-2010
    Location
    Barcelona, Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Question Clicking a cell should trigger a MsgBox with specific details

    Hello,

    I am trying to get the following to work:

    I have a table with values in it. Each value is a sum of other values which are located on different sheets in the same excel workbook. In order to add the values for each cell I am using several SUM() matrix formulas which works great.

    What I would like to do is when I click on a value in my table, I would like to get some sort of pop-up box that lists all the values that were used in summing up to that value.

    For example the table goes from K8:V16
    The value in T10 is 1200, which is the sum of several other numbers

    The sum of T10 actually is:
    Bus Ticket 20 EUR
    Restaurant 200 EUR
    Computer 900 EUR
    Documents 80 EUR

    The reason the matrix formula sums all of this up is because all the expenses occurred on the same day (e.g. Oct 1, 2010)

    So what I would like is that when I click T10, that I get a list of these expenses in a pop-up box (showing a list similar to the one above). And of course, if I click T11, I should get a different list, just as if I click U10 or any other cell in the table I should get the values and names of the expenses that add up to that cell.

    I was thinking of using MsgBox, but I don't know how to:
    1) trigger a VBA script through a single click on a cell
    2) recognize which cell is triggering the event
    3) using the information in the cell to find in adjacent sheets which values were used to add up to the total
    4) instead of 3 above, or in addition: I know how to use VLOOKUP, which gives me ONE value in return, but don't know what to use to get all values...maybe using a loop?

    Thank you in advance. I know that this is probably not easy, maybe we can tackle it step by step, and I will test and see.



    I am using Excel 2010, but if possible would like to write a script that works on Excel 2003 also.

    Cheers,
    SSDLFUN
    Last edited by ssdlfun; 11-04-2010 at 08:18 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Clicking a cell should trigger a MsgBox with specific details

    Please post a sample file.

    Can we ask why you're not using a Pivot Table which would seem to offer you all of the functionality you require by default ?

  3. #3
    Registered User
    Join Date
    11-04-2010
    Location
    Barcelona, Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Clicking a cell should trigger a MsgBox with specific details

    Thank you for the reply.

    Attached you can find a "Sample.xlsx" file which should almost be self explanatory.

    What I am trying to do is the following:
    1) On sheet "Summary 2010 (new)" i would like to click on cell M10 and see a pop-up with the summary of what charges are adding up to that value
    2) I would like to be able to click on any cell in that table and get the same effect.

    In the case of M10 I would like to see a pop-up box next (or close to the cell) -- i.e. relative to the cell with the following information:
    John - 15 EUR
    - 1 Oct - Taxi with friend - 15 EUR

    Peter - 42 EUR
    - 1 Oct - Returning from Lunch - 10 EUR
    - 1 Oct - Taxi for a friend - 15 EUR
    - 5 Oct - Taxi going to lunch - 10 EUR
    - 5 Oct - Taxi coming from lunch - 7 EUR

    Total - 57 EUR
    If I clicked on a different cell I would like to get the summary of that cell instead.

    Please ask if it is not clear, like that I can try to explain better.

    The reason I am not using Pivot Tables is because the attached file is a simplification of what I am doing and the matrix formulas that I am using are really not a problem for me. I am just trying to get a pop-up box with this information next to the relevant cell.

    Thank you for your help!!
    Attached Files Attached Files

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

    Re: Clicking a cell should trigger a MsgBox with specific details

    If you designed the spreadsheet properly you could use Donkey's suggestion
    Hope that helps.

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

    Free DataBaseForm example

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Clicking a cell should trigger a MsgBox with specific details

    I have to say that from a drill down perspective pursuing Pivots is something of a no brainer irrespective of your ability with formulae - you are in essence looking to recreate the wheel.
    (the 3D nature of your set up will not lend itself to this task however... Multi Consolidation Pivots have limited flexibility - from a design perspective it is always better to have a single repository)

    I would also take this opportunity to state that matrices of Arrays are bad news (always) ... it is likely that they will come back to haunt you from a performance perspective.

    IMO (FWIW) you should add a key to your individual sheets such that you can revert to the much more efficient SUMIF* with concatenated criteria compared to concatenated key
    *SUMIFS obviously excluded given backwards compatibility requirements

    In terms of drill down without Pivots - you're looking at:

    1 - using the Double Click Event to trap the intent
    2 - iterating all appropriate worksheets
    3 - applying Filters to each iterate sheet based on intersecting "Header" values of the Target Cell
    4 - copying the visible cells (post filter less header) and writing to the newly created sheet (obviously adding each subset after the other so as not to overwrite)
    the above is not something I have time to do myself presently but should hopefully act as a pointer if nothing else
    Last edited by DonkeyOte; 11-05-2010 at 07:36 AM. Reason: missing all important word in narrative...

  6. #6
    Registered User
    Join Date
    11-04-2010
    Location
    Barcelona, Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Clicking a cell should trigger a MsgBox with specific details

    @royUK: not sure how to design the spreadsheet "properly", since the "John" and "Peter" sheets are going to be filled out by different people. I guess I could consolidate them into one sheet and then use the Pivot Table, but I am trying to keep the interface as is. Regardless, I am not sure how a Pivot Table gives you the summary of the summed number in a pop-up? Is there a feature I am missing?

    @Donkey: thank you for your suggestions and help. Not sure what you mean by "adding a *key* to the individual sheets to revert to SUMIF. Additionally I used to find SUMIF to be limited, though more efficient when trying to sum using several criteria. Maybe SUMIFS does that now, though as you mention would not be backward compatible.

    To tackle step by step:
    Can someone help me with writing a VBA script in EXCEL which is triggered by a single click on a cell in a table, and then getting a pop-up with a list of the following information: a) the row number, b) the column number, c) the value of the cell, and d) the formula in the cell

    So the pop-up would be something like:
    - Row:10
    - Column: M
    - Value: 57 EUR
    - Formula: "=SUM(('Peter 2010'!$H$6:$H$958=$C10)*('Peter 2010'!$E$6:$E$958=M$6)*('Peter 2010'!$J$6:$J$958))+SUM(('John 2010'!$H$6:$H$1866=$C10)*('John 2010'!$E$6:$E$1866=M$6)*('John 2010'!$J$6:$J$1866))"

    Thank you!

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

    Re: Clicking a cell should trigger a MsgBox with specific details

    You can't pop up in a pivottable, you can drill down & it is more efficient than array formulas and VBA

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Clicking a cell should trigger a MsgBox with specific details

    Quote Originally Posted by ssdlfun View Post
    @Donkey: Not sure what you mean by "adding a *key* to the individual sheets to revert to SUMIF.
    Consider A1:C10000 of:

    Please Login or Register  to view this content.
    Now consider we want to SUM C where A is "a" and B is "z"

    Prior to XL2007 we could as you have shown use an Array or SUMPRODUCT equiv.

    Please Login or Register  to view this content.
    However these formulae are inefficient... prior to XL2007+ a good alternative is to concatenate fields of interest, eg:

    Please Login or Register  to view this content.
    We can now dispense with inefficient formulae and revert to SUMIF using a concatenated criteria

    Please Login or Register  to view this content.
    used in large volume and/or with large ranges and/or in volatile context the gain from the SUMIF approach is likely to prove significant.

    SUMIF also offers wildcard functionality so if we wanted to just search for "non-blank@z" then:

    Please Login or Register  to view this content.
    a well constructed key offers lots of flexibility and in an efficient manner.

    With Excel as you know Elegance and Efficiency do not always equate to the same and Efficiency is always the more important consideration (IMO)

    *also have D functions... but can prove cumbersome depending on configuration

  9. #9
    Registered User
    Join Date
    11-04-2010
    Location
    Barcelona, Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Clicking a cell should trigger a MsgBox with specific details

    @royUK: that is true, when I write a spreadsheet for myself, I use PivotTables. This time the spreadsheet is for my parents, they don't even know what Excel is, so I am trying to make it simple. When they see a number and want to know what is behind it, I would like it to be intuitive and for them to get some details on the number when clicking...

    @DonkeyOte: I see what you mean. In my case I guess I could use SUMIFS, though SUMIF is not enough given that I am using more than one criteria. Nevertheless I am actually summing more than one column in my real spreadsheet, which would probably not work with SUMIFS, unless I used a support column and then added them together. Regardless, I think I will use SUMIFS to make it smoother, though need to see the backward compatibility on that with Excel 2003. Thanks for your explanations!

    Given all this, I am going back to the step by step approach...first figuring out how to make a pop-up with the information of the cell that triggered the event.
    Can anyone help with this first step?

    Thanks so far!
    Last edited by ssdlfun; 11-05-2010 at 08:53 AM.

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Clicking a cell should trigger a MsgBox with specific details

    Quote Originally Posted by ssdlfun View Post
    @DonkeyOte: ...though SUMIF is not enough given that I am using more than one criteria.
    I can only guess from the above that you did not follow the example I provided ?

    Quote Originally Posted by ssdlfun
    Nevertheless I am actually summing more than one column in my real spreadsheet, which would probably not work with SUMIFS, unless I used a support column and then added them together
    Correct - that holds true for both SUMIF & SUMIFS
    (unless dimensions of criteria tests match the summation range - which they won't here).

    Quote Originally Posted by ssdlfun
    Regardless, I think I will use SUMIFS to make it smoother, though need to see the backward compatibility on that with Excel 2003.
    If you need backwards compatibility then you can not use SUMIFS.

    Quote Originally Posted by ssdlfun
    Given all this, I am going back to the step by step approach...first figuring out how to make a pop-up with the information of the cell that triggered the event.
    Can anyone help with this first step?
    See the Selection Change event, however, I can only reiterate that this is not the method you should be pursuing... given you are seemingly intent on this approach I confess I bow out at this point.

  11. #11
    Registered User
    Join Date
    11-04-2010
    Location
    Barcelona, Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Clicking a cell should trigger a MsgBox with specific details

    Quote Originally Posted by DonkeyOte View Post
    I can only guess from the above that you did not follow the example I provided ?
    I did follow your examples (I think I did it right...maybe I am not doing it right). With SUMPRODUCT you are right, though wtih SUMIF it does not seem like I can do more than one criteria (??)


    See the Selection Change event, however, I can only reiterate that this is not the method you should be pursuing... given you are seemingly intent on this approach I confess I bow out at this point.
    The only thing I can say is what I said above again:
    This time the spreadsheet is for my parents, they don't even know what Excel is, so I am trying to make it simple. When they see a number and want to know what is behind it, I would like it to be intuitive and for them to get some details on the number when clicking...

    If you have another suggestion on how to provide someone with detailed information who does not know Excel at all, or almost computers, I am happy to hear it. The type of detailed information is not that deep, it should only be a summary of what values were added to come up with the final number.

    Thanks so far! Really!

  12. #12
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Clicking a cell should trigger a MsgBox with specific details

    I can't see your spreadsheet because I don't have Excel 2007. If you are set on doing things your way against the suggestions of others, then so be it. Try using an amendment of the code below to have a validation popup whenever a cell is clicked. It contains the row, column, amount, and formula within that cell.

    Note: As it is setup, the code is only going to work for column A, but you can change that as necessary. This code should be input into the worksheet code for the applicable sheet. Let me know if it helps at all.
    Please Login or Register  to view this content.

  13. #13
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Clicking a cell should trigger a MsgBox with specific details

    Quote Originally Posted by ssdlfun View Post
    I did follow your examples (I think I did it right...maybe I am not doing it right). With SUMPRODUCT you are right, though wtih SUMIF it does not seem like I can do more than one criteria (??)
    It seems given your prior point re: summation dimension that this is a moot discussion but multiple criteria is the purpose of the concatenation, no ?

    Please Login or Register  to view this content.
    the above uses two criteria - a & z the two being merged into a single condition by virtue of concatenated key column (D at source)

    If you mean you want multiple "multiple" criteria - ie "a@z" and "b@z" then

    Please Login or Register  to view this content.
    Quote Originally Posted by ssdlfun
    If you have another suggestion on how to provide someone with detailed information who does not know Excel at all, or almost computers, I am happy to hear it.
    I believe I've offered some pointers on all aspects.

  14. #14
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Clicking a cell should trigger a MsgBox with specific details

    Perhaps you could use this UDF.

    A cell holding the formula
    =ThreeFormulas(A1+B2+C3, "Car fare:"&A1&CHAR(13) &"Ticket:"&B2&CHAR(13) &"Dinner:"&C3)
    will display the sum in the first argument. Selecting that cell will show a validation input message determined by the second argument. (and the third, if it exists)
    Please Login or Register  to view this content.
    Last edited by mikerickson; 11-05-2010 at 10:19 AM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  15. #15
    Registered User
    Join Date
    11-04-2010
    Location
    Barcelona, Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Clicking a cell should trigger a MsgBox with specific details

    Hello BigBas!

    Wow, this looks really great. Exactly what I wanted. I just need to play around with it a little bit and then add some iteration code to it, but for now THANK YOU!

    Cheers!

    p.s. I will work on this and get back with the next step in a few. Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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