Just adding this to close the thread with my final solution.
This method will put an * into Column G for each visible item after filtering Contacts.
It will remove the markers to prevent an error occurring when users run it a 2nd time without removing the filters.
Not very efficient when a Stakeholder has a lot of items, but this seems to work okay in 2010, and should work for 2003 as well.
Column headings are in Row 5 now due to user instructions and buttons being at top of page.
Column G is not hidden, but is very small.
The top macro, Unfilter, simply removes all filters to reset the report.
Option Base 1
Sub Unfilter()
' Removes all filters from the page to reset the report.
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
Range("A5").Select
End Sub
Public Sub FilterByVisibleContacts()
Dim myArray()
Application.ScreenUpdating = False
On Error Resume Next 'to bypass error from lazy method used to designate a range.
ReDim Preserve myArray(1)
lp = 0
For Each VisibleCell In Range("A5:A10000").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants, 2)
lp = lp + 1
If NewValue(myArray, VisibleCell.Value) Then
ReDim Preserve myArray(lp)
myArray(lp) = VisibleCell.Value
End If
Next VisibleCell
For x = 1 To lp
ActiveSheet.ShowAllData
ActiveSheet.Range("$A5:$G10000").AutoFilter Field:=1, Criteria1:=myArray(x)
Range("G4").Select
For Each VisibleCell In Range("A5:A10000").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants, 2)
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.EntireRow.Hidden = False
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Value = "*"
Next VisibleCell
Next x
ActiveSheet.ShowAllData
ActiveSheet.Range("$A$4:$G$10000").AutoFilter Field:=7, Criteria1:="<>"
Range("A4").Select
ActiveCell.Offset(1, 0).Select
Range("G5:G10000").ClearContents
Application.ScreenUpdating = True
End Sub
Public Function NewValue(myArray, CurrValue As String) As Boolean
NewValue = True
For i = 1 To UBound(myArray)
If myArray(i) = CurrValue Then
NewValue = False
Exit Function
End If
Next i
End Function
Bookmarks