![]() |
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 |
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 |
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, |
All times are GMT +1. The time now is 02:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com