View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default Filtering Columns

Hi Chris,
Hope u had a great weekend!!!

Thanks a bunch for your solution; solved my purpose except for this loop:
'Find out what row we're in
Do Until Right(strDummy, 1) = "$"
strActiveRow = strActiveRow & Right(strDummy, 1)
strDummy = Left(strDummy, Len(strDummy) - 1)
Loop


When i double click on row 1; code does filter the columns and displays
correct results...and same results untill row 9. From row 10 it fails to
filter; for my curiosity i found that row 11 and multiples of 11 like (row
22, 33, 44, 55....) does give correct filtered result. Could you check this
loop. Thanks.

regards,
Mike.

"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