Hi all! So i have two problems -
Firstly, I have a code that when you press save on a document, my spreadsheet turns off the autofilter before saving. However I have noticed that when people press Exit then when prompted select save - the autofilter is NOT turned off. I would like the autofilter to turn off no matter how i save the document.
Here is the code:
Sub Macro1()
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:=Range _
("H3:H1302"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
The second problem is that on my workbook there is a button that you press called the caller button which opens up a form to populate my spreadsheet. The issue that I am having is that I would like when you press this button the filter turns OFF, then the form appears. I tried to adapt my above code to do this, but it doesn't seem to be working:
Sub OpenCallerForm()
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:=Range _
("H3:H1302"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Worksheets("Sheet1").Activate
frmCaller.Show
End Sub
Thanks very much!
Bookmarks