LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default vb to Unselect a Filter Value

Thanks for all the help... I simplied the code a bit... No need to have the
extra error checks at this time...

Here were the resulting lines....

colNumber = Columns("D").Column
ActiveSheet.Cells.AutoFilter field:=colNumber, Criteria1:="<C"

Thank you for the education. I have just earned one brain cell back.

Don

"OssieMac" wrote:

I was not sure of exactly what you wanted. Anyway the code I gave you tests
all columns in the AutoFilter range. The following just tests column G.

I have assigned the column number of G to a variable. However, you need to
realize that this only works if the Autofilter columns start at column A
because the number required in the code is the number of the column in
Autofilter; not necessarily the worksheet column number. If say you have say
3 blank columns to the left of the autofiltered data then column 7 of the
Autofiltered data would not match column 7 of the worksheet and you would
need to specifically assign the autofilter column number to the variable.

As per my earlier comment, feel free to get back to me again if still not
what you want.

Sub FilterExample_4()
Dim ws As Worksheet
Dim strFilter As String
Dim colNumber As Long

'Convert column alpha Id to numeric
'Assumes that Autofilter columns start
'at column A.
colNumber = Columns("G").Column

Set ws = Worksheets("Sheet1")

With ws
'Test that AutoFilter is turned on
'(If turned off remaining code errors)
If .AutoFilterMode Then
'Test if filter colNumber is applied
With .AutoFilter
If .Filters(colNumber).On Then
'Assign filter value to variable
strFilter = .Filters(colNumber).Criteria1
If UCase(strFilter) = "=C" Then
'Turn off filter colNumber
.Range.AutoFilter Field:=colNumber
End If
End If
End With
Else
MsgBox "Autofilter is not turned on"
End If
End With

End Sub

--
Regards,

OssieMac



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
unselect cells tgi Excel Discussion (Misc queries) 1 October 1st 09 03:21 AM
unselect cells tgi Excel Discussion (Misc queries) 2 October 1st 09 01:39 AM
Unselect Cells bobwilson[_12_] Excel Programming 6 April 4th 06 12:02 AM
How to unselect? Kou Vang[_2_] Excel Programming 3 January 26th 06 02:54 PM
Unselect Filtre .... sal21[_12_] Excel Programming 1 February 23rd 04 01:54 PM


All times are GMT +1. The time now is 06:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"