hiding cells that contain certain text

k_babb

Board Regular
Joined
Mar 28, 2011
Messages
71
Hi i am trying to sort out my code so that it will hide all rows on the sheets listed in column b that contain a z it works on Jan sheet but will not do the other sheets listed. I am new to this coding so there is probably a really basic error any help would be great also is there a way to speed up the macro as it takes a long time to complete on one sheet let alone 12 sheets maybe there is away to detect which row has been updated?
Code:
Public Sub hidden() Dim Rownum As Long, ws As Worksheet Sheets("Jan ").Select BeginRow = 7 EndRow = 250 ChkCol = 2 ActiveWindow.DisplayZeros = False Application.ScreenUpdating = False          On Error Resume Next     With ThisWorkbook         For Each ws In .Worksheets             Select Case ws.Name                 Case "Jan ", "Feb ", "Mar ", "Apr ", "May ", "Jun ", "Jul ", "Aug ", "Sep ", "Oct ", "Nov ", "Dec "                     For RowCnt = BeginRow To EndRow         If Cells(RowCnt, ChkCol).Value = "z" Then             Cells(RowCnt, ChkCol).EntireRow.hidden = True             Else             Cells(RowCnt, ChkCol).EntireRow.hidden = False           End If     Next RowCnt                                                           Case Else                     'do nothing             End Select         Next ws     End With           Application.ScreenUpdating = True     End Sub</pre>
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Code:
For RowCnt = BeginRow To EndRow
    If ws.Cells(RowCnt, ChkCol).Value = "z" Then
        ws.Cells(RowCnt, ChkCol).EntireRow.hidden = True
    Else
        ws.Cells(RowCnt, ChkCol).EntireRow.hidden = False
    End If
Next RowCnt
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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