VBA for Hiding or Removing all Zero Values from Specific Worksheet Tabs

njpamdnc

New Member
Joined
Feb 16, 2019
Messages
42
Office Version
  1. 2007
Platform
  1. Windows
Hello...My name is Robert, and I am an intermediate school math teacher who is trying to remove zero values from certain worksheets in my Excel gradebook. I know for a fact the Macro below this message executes. However, I need the macro to execute for multiple and specific worksheet tabs. The names of the worksheet tabs being referenced begin with q1, q2, q3 and q4. Therefore, I'm thinking maybe the VBA syntax will be q1*, q2*, q3* and q4*.

Sub Hide0()
ActiveWindow.DisplayZeros = False
End Sub
 
Another option
VBA Code:
Option Explicit
Option Compare Text
Sub HideZeros()
Dim ws As Worksheet, i As Long, q
Application.ScreenUpdating = False

q = Array("q1*", "q2*", "q3*", "q4*")
For Each ws In ThisWorkbook.Worksheets
    For i = LBound(q) To UBound(q)
        If ws.Name Like q(i) Then
            ws.UsedRange.NumberFormat = "#"
        End If
    Next i
Next ws

Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
A post #2 variant still seems like the simplest method.

VBA Code:
Sub HideZeros2()
'
    Dim ws As Worksheet
    Dim W As Window
    Application.ScreenUpdating = False
    '
    For Each W In Application.Windows
        If Left(W.Caption, 9) = "gradebook" Then
            W.Activate
            For Each ws In ThisWorkbook.Worksheets
                If (ws.Name Like "q1*" Or ws.Name Like "q2*" Or ws.Name Like "q3*" Or ws.Name Like "q4*") Then
                    ws.Activate
                    ActiveWindow.DisplayZeros = False
                End If
            Next ws
        End If
    Next W
    Application.ScreenUpdating = True
End Sub

Complete success has finally been achieved. Thank you very much!!!
 
Upvote 0
As more or less suggested in Post #6, would you not be able to change your formulae with a macro?
We have not seen, at least I have not, your formulae but AFAIK, that can't be that difficult.
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

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