View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
cht13er cht13er is offline
external usenet poster
 
Posts: 141
Default Filtering Columns

On Mar 17, 8:12 pm, cht13er wrote:
On Mar 17, 5:25 pm, Mike wrote:



Hi MVP's/MS Geeks:
Am looking for a way out; could anyone in group bail me out. I have table
whose Column A forms a vertical heading range [A1:A10]& Row 2 forms the
horizontal heading range [B1:N1]. The data range is [B2 : N10]. I would like
to program in such way that by clicking on any cell of Vertical heading (for
e.g. A5) displays a filtered data with a criteria that only those columns
against A5(or of row 5) whose value is between 1-100 (Hides those columns
who fails to meet the criteria).


In short i need buttons on each cell of vertical heading [A2:A10] and
program each button to meet the criteria that filters/displays only those
columns whose value is between 1 & 100, hides the rest; upon selecting any of
the button


xpecting a Easter egg solution; pretty much appreciated...
thanxs...


Try putting this in the sheet's code:
'------------------
Option Explicit

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

'Declarations
Dim strActiveColumn As String
Dim strDummy As String
Dim strActiveRow As String
Dim iCounter As Integer

'Unhide all columns
For iCounter = 2 To 14
Columns(iCounter).Hidden = False
Next iCounter

'Make sure we're in column 'A'
strActiveColumn = Mid(ActiveCell.Address, 2, 1)

If strActiveColumn = "A" Then
strDummy = ActiveCell.Address

'Find out what row we're in
Do Until Right(strDummy, 1) = "$"
strActiveRow = strActiveRow & Right(strDummy, 1)
strDummy = Left(strDummy, Len(strDummy) - 1)
Loop

'Test each column in the row for a value = 100, if less, hide.
For iCounter = 2 To 14
If Cells(strActiveRow, iCounter) < 100 Then
Cells(strActiveRow, iCounter).EntireColumn.Hidden =
True
End If
Next iCounter
End If
End Sub

Double click on any entry in column A to "filter" and double click
anywhere else to undo the filtering .... this is pretty neat!

Chris


ps. If you want to be able to "filter" by more than just "100" (e.g.
filter by <200, or =75) (user enters the desired filter onto the
sheet) I have some code for that - just let me know!

C