Hide columns with zero or blank after filter

Accountant88

New Member
Joined
Oct 16, 2021
Messages
6
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Hi

I have a spreadsheet with so many columns and rows. I am looking for a macro to filter the product in Column A, cell 2; then hide any columns in the range from BU to CW with zero value or no value. Can anyone help please?
 
Maybe try this

VBA Code:
Sub HideColumnsWhenAllRowsAreZero()
For A = 73 To 101
    If Application.WorksheetFunction.Sum(Range(Cells(1, A), Cells(Cells(Rows.Count, A).End(xlUp).Row, , A)).SpecialCells(xlCellTypeVisible)) Then
        Columns(A).EntireColumn.Hidden = True
    End If
Next A
End Sub
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
oops

meant this

VBA Code:
Sub HideColumnsWhenAllRowsAreZero()
For A = 73 To 101
    If Application.WorksheetFunction.Sum(Range(Cells(1, A), Cells(Cells(Rows.Count, A).End(xlUp).Row, , A)).SpecialCells(xlCellTypeVisible)) =0 Then
        Columns(A).EntireColumn.Hidden = True
    End If
Next A
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,215
Members
448,874
Latest member
b1step2far

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top