Hello All
I was hoping if you could help me out on an issue I am having with my autofilters.
I added the error codes below to help with the troubleshooting.
How do you get rid of / remove the autofilter?
I have a searchform that uses autofilters.
FIND ALL SECTION
Works fine. The autofilter is setup between columns B to I
CLOSE FORM SECTION
I made a close button to close the form. But when I close the form I want the autofilter to be removed, vanished, no little arrows, nothing!
This is what I have.
I get the following errors:
1) Run Time Error 1004
Method 'ShowAllData' of object' _Worksheet' failed
2) When I press "debug" the line of code in question is
3) The autofilter is not removed. I can still see the arrows and rows are missing meaning the autofilter is still applied.
I tried the following code. It doesn't bring up the error BUT it doesn't remove the autofilter
Your advice is desperately sought.
I tried to be as specific as possible
Thanks.
I was hoping if you could help me out on an issue I am having with my autofilters.
I added the error codes below to help with the troubleshooting.
How do you get rid of / remove the autofilter?
I have a searchform that uses autofilters.
FIND ALL SECTION
Works fine. The autofilter is setup between columns B to I
Code:
Sub cmbFindAllKoreanName_Click()
Dim strFind As String 'what to find
Dim rFilter As Range 'range to search
Set rFilter = Sheet10.Range("b2", Range("i65536").End(xlUp))
Set rng = Sheet10.Range("b2", Range("b65536").End(xlUp))
strFind = Me.txtKoreanName.Value
With Sheet10
If Not .AutoFilterMode Then .Range("b2", Range("i65536")).AutoFilter
rFilter.AutoFilter field:=1, Criteria1:=strFind
Set rng = rng.Cells.SpecialCells(xlCellTypeVisible)
Me.ListBox1.Clear
For Each c In rng
With Me.ListBox1
.AddItem c.Value
.List(.ListCount - 1, 1) = c.Offset(0, 1).Value
.List(.ListCount - 1, 2) = c.Offset(0, 2).Value
.List(.ListCount - 1, 3) = c.Offset(0, 3).Value
.List(.ListCount - 1, 4) = c.Offset(0, 4).Value
.List(.ListCount - 1, 5) = c.Offset(0, 5).Value
.List(.ListCount - 1, 6) = c.Offset(0, 6).Value
.List(.ListCount - 1, 7) = c.Offset(0, 7).Value
.List(.ListCount - 1, 8) = c.Offset(0, 8).Value
End With
Next c
End With
End Sub
CLOSE FORM SECTION
I made a close button to close the form. But when I close the form I want the autofilter to be removed, vanished, no little arrows, nothing!
This is what I have.
Code:
Private Sub cmdClose_Click()
Unload Me ' Close the current form
frmPersonal.Show
If Sheet10.AutoFilterMode Then Sheet10.ShowAllData
Application.ScreenUpdating = True
End Sub
I get the following errors:
1) Run Time Error 1004
Method 'ShowAllData' of object' _Worksheet' failed
2) When I press "debug" the line of code in question is
Code:
If Sheet10.AutoFilterMode Then Sheet10.ShowAllData
3) The autofilter is not removed. I can still see the arrows and rows are missing meaning the autofilter is still applied.
I tried the following code. It doesn't bring up the error BUT it doesn't remove the autofilter
Code:
If Sheet10.AutoFilterMode = True Then Sheet10.AutoFilsterMode = False
Your advice is desperately sought.
I tried to be as specific as possible
Thanks.