Hello,
I'm looking to see if there is a way to combine multiple string values to validate against in a more concise way than I am currently.
I use a macro that clears all filters. However, there are three Tables in particular that I often want to Sort afterwards.
Maybe I can use an array with those three string values. Something that says IF the TableName is any of the following: ("tblBooks", "tblStudents", "tblMSBs") Then Sort
Although I can achieve these results with the following, I was hoping I didn't have to list them three times:
Thank you,
I'm looking to see if there is a way to combine multiple string values to validate against in a more concise way than I am currently.
I use a macro that clears all filters. However, there are three Tables in particular that I often want to Sort afterwards.
Maybe I can use an array with those three string values. Something that says IF the TableName is any of the following: ("tblBooks", "tblStudents", "tblMSBs") Then Sort
Although I can achieve these results with the following, I was hoping I didn't have to list them three times:
VBA Code:
Sub ClearFilters()
'Clear Filters
On Error Resume Next
ActiveSheet.ShowAllData
'Sort by Title
Dim TableName As String
TableName = ActiveCell.ListObject.Name
If TableName = "tblBooks" Or _
TableName = "tblStudents" Or _
TableName = "tblMSBs" Then
SortTitle 'Calling Sub
ActiveWindow.ScrollRow = 1
ActiveSheet.ListObjects(1).HeaderRowRange(1).Select
End If
End Sub
Thank you,
Last edited: