VBA to unfilter all columns

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,759
Office Version
  1. 365
Platform
  1. Windows
Is there a way to unfilter columns using code? I have code that chokes if the user has any filters on. I want to in-filter all before my code runs.
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

ZVI

MrExcel MVP
Joined
Apr 9, 2008
Messages
3,749
Office Version
  1. 2016
  2. 2010
  3. 2007
Platform
  1. Windows
Try for columns: ActiveSheet.Columns.Hidden = False
For rows: ActiveSheet.Rows.Hidden = False
For both: ActiveSheet.Cells.Hidden = False
 
Last edited:

ZVI

MrExcel MVP
Joined
Apr 9, 2008
Messages
3,749
Office Version
  1. 2016
  2. 2010
  3. 2007
Platform
  1. Windows
My ActiveSheet.Cells.Hidden = False is wrong :(
More correct:
Rich (BB code):
Sub UnhideColumns()
  ActiveSheet.Columns.Hidden = False
End Sub
 
Sub UnhideRows()
  If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
  ActiveSheet.Rows.Hidden = False
End Sub
 
Sub UnhideAll()
  UnhideColumns
  UnhideRows
End Sub
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,114,652
Messages
5,549,210
Members
410,905
Latest member
Extjel
Top