#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default unfilter

hi,
In VBA, how can I restore filter before saving.for example, in sheet1 the
rows10 to 20 are invisible(filtered), I need a code by which
unfilter the worksheet ( all the worksheets,if they are in filter mode) with
no invisible rows and then save the workbook?
thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default unfilter

Range("A9").autofilter
(assumes A9 is one of the title rows of the data which is filtered.

"peyman" wrote in message
...
hi,
In VBA, how can I restore filter before saving.for example, in sheet1 the
rows10 to 20 are invisible(filtered), I need a code by which
unfilter the worksheet ( all the worksheets,if they are in filter mode)
with
no invisible rows and then save the workbook?
thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default unfilter

On Oct 26, 7:21 pm, peyman wrote:
hi,
In VBA, how can I restore filter before saving.for example, in sheet1 the
rows10 to 20 are invisible(filtered), I need a code by which
unfilter the worksheet ( all the worksheets,if they are in filter mode) with
no invisible rows and then save the workbook?
thanks


hey peyman,

you need to go to Visual Basic window, double click on ThisWorkbook
object of your excel file and insert the following code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
For i = 1 To Sheets.Count
Worksheets(i).Select
If Worksheets(i).AutoFilterMode = True Then
Cells.Select
Selection.AutoFilter
Cells(1, 1).Select
End If
Next i
End Sub

Before saving, this code will check every sheet for filters and remove
them.

Best,


Reply
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



All times are GMT +1. The time now is 01:39 PM.

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"