Results 1 to 5 of 5

Thread: [RESOLVED] Block user from turning filter on manually - Dynamically Set AutoFilter to UsedRange.

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    222

    Resolved [RESOLVED] Block user from turning filter on manually - Dynamically Set AutoFilter to UsedRange.

    This code works well for turning on the Auto Filter
    for a dynamically determined used range if the filter happens to accidentally be turned off.

    My reason for it is because the Row Headers are on row 15, but there is also data on rows 1 thru 14

    * I would like to disable the ability for the user to turn the filter on manually.

    The method will need to work in both Excel 2003 and 2007

    Thanks in advance for any ideas.
    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    'If Filter is off, this code works well to turn it on to a semi-dynamically determined UsedRange
    
    Dim rng As Range
    Dim wks As Object
    Dim LastRow As Long
    
    Set wks = ActiveSheet
    
    With wks
       LastRow = .[B65536].End(xlUp).Row
       Set rng = .Range(.Cells(15, 1), .Cells(LastRow, 23))'Range= Row(15) to Col(23) to Last data Row
     
       If Not .AutoFilterMode Then
           rng.AutoFilter
       End If
        
          .EnableAutoFilter = True
    End With
    
    End Sub
    Last edited by SQLADOman; Jun 13th, 2010 at 09:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width