fishandtril
New Member
- Joined
- Nov 15, 2022
- Messages
- 13
- Office Version
- 365
- 2021
- Platform
- Windows
Is there a way to join these two pieces of code so the one button executes the code depending on what is shown. currently I have two macros; one to filter the data and another to clear the filter and unhide columns.
VBA Code:
Sub Customer_Sales_Profile()
'
' Calculate Unique Range then Filter for all rows = "Show"
'
ActiveSheet.Calculate
Rows("1:1").Select
Columns("A:G").Select
Selection.EntireColumn.Hidden = False
ActiveSheet.Range("$A$1:$F$844").AutoFilter Field:=1, Criteria1:="Show"
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
Range("A1").Select
End Sub
Sub Customer_Sales_Profile_Clear()
'
' Clear the filters and unide columns
'
Columns("A:A").Select
Selection.EntireColumn.Hidden = False
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilter.ShowAllData
Range("A1").Select
End Sub