Forum Discussion
JShearer98
Sep 09, 2025Copper Contributor
Macro to filter table to a searched result, then hide columns that contain a blank or a set value.
Hi All, I'm trying to figure out how to do the above. Essentially I have a list of assemblies and along the same row is a list of each part within that assembly. Not every sub-part is used in eac...
- Sep 09, 2025
Does this do what you want?
Sub SEARCH() Dim rng As Range Application.ScreenUpdating = False Range("B2:W2").EntireColumn.Hidden = False If Range("B2") <> "" Then Range("B5").AutoFilter Field:=1, Criteria1:=Range("B2").Value On Error Resume Next Set rng = Range("B" & Rows.Count).End(xlUp).Resize(1, 22).SpecialCells(xlCellTypeBlanks) On Error GoTo 0 If Not rng Is Nothing Then rng.EntireColumn.Hidden = True End If End If Application.ScreenUpdating = True End Sub
HansVogelaar
Sep 09, 2025MVP
Does this do what you want?
Sub SEARCH()
Dim rng As Range
Application.ScreenUpdating = False
Range("B2:W2").EntireColumn.Hidden = False
If Range("B2") <> "" Then
Range("B5").AutoFilter Field:=1, Criteria1:=Range("B2").Value
On Error Resume Next
Set rng = Range("B" & Rows.Count).End(xlUp).Resize(1, 22).SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If Not rng Is Nothing Then
rng.EntireColumn.Hidden = True
End If
End If
Application.ScreenUpdating = True
End Sub
JShearer98
Sep 18, 2025Copper Contributor
Hi HansVogelaar,
That works perfectly, thank you very much