Click on a cell count and view results

  • Thread starter Thread starter ryan.bleam
  • Start date Start date
R

ryan.bleam

Hello all,
So I have a set of data on one sheet and some formulas on another. I
calculate the count using a countif which references the sheet with
the data on. So for example if I have a certain amount in a document
type the countif formula counts how many of these document types are
in the data set and displays the count in the table. I'd like to be
able to click on the cell that shows the count and have a macro that
displays all of the documents that make up that count. Can anyone help
me out with this?
 
You can use the Worksheet_SelectionChange event to monitor when the user
selects a particular cell, and then take action. Something like (insert this
code into the worksheet with the formulas on it):

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'
If (Target.Areas.Count = 1 And Target.Cells.Count = 1 And _
Target.Row = myRow and Target.Column = myColumn) Then

' The user selected a cell of interest, so do something here...
' (here is where you can loop through the data on the second sheet
' and find matching entries. If you have a space reserved on the
first
' to list all the matching data types, clear that space out and then
' update the list according to which cell the user selected)

End If
'
End Sub

Of course, you get to fill in the blanks in the VBA. Holler if you need a
little more help.

HTH,

Eric
 
Back
Top