VBA Help: Hide all Columns that have a "N/A" in the total line

JazzyJellyB

New Member
Joined
Jan 22, 2016
Messages
31
I have looked over this forum for days so I have to break down and ask.

I have several tabs (25) and 30+ columns with identical formatting that look like this:
PROD1PROD2PROD3PROD4
XXXX1111222203333
YYYY1122044
ZZZZ1101
ABAB22N/A2

<tbody>
</tbody>

I am trying to find a VBA code that will hide any column in each spreadsheet where "N/A" is found.

Thanks in advance.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Your solution should really be to prevent the NA's from occurring in the first place, perhaps using

=IFERROR(formula,"")
 
Last edited:
Upvote 0
I found this from an earlier post! I am sorry I can't remember the orginal person that came up with it. I just edited it.

Sub HideColumns()
Application.ScreenUpdating = False
For i = 26 To 1 Step -1
If Cells(2, i).Value <> "" Then
If Cells(2, i).Value = 0 Then Columns(i).Hidden = True
End If
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,831
Members
449,051
Latest member
excelquestion515

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