Hide Rows

Tahas

Board Regular
Joined
Sep 10, 2008
Messages
166
Hi Friends,

I have a spreadsheet with staff names which appears multiple times.
I’m trying to create a macro that would hide staff names as per the macro below which only selects the first name and only once.

Sub HURows()
BeginRow = 1
EndRow = 500
ChkCol = 2
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = "Andy", Or “Mike”, or “Tom” Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
How about
VBA Code:
Sub HURows()
   BeginRow = 1
   Endrow = 500
   ChkCol = 2
   For RowCnt = BeginRow To Endrow
      Select Case Cells(RowCnt, ChkCol).Value
         Case "Andy", "Mike", "Tom"
            Rows(RowCnt).Hidden = True
         Case Else
            Rows(RowCnt).Hidden = False
      End Select
   Next RowCnt
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub HURows()
   BeginRow = 1
   Endrow = 500
   ChkCol = 2
   For RowCnt = BeginRow To Endrow
      Select Case Cells(RowCnt, ChkCol).Value
         Case "Andy", "Mike", "Tom"
            Rows(RowCnt).Hidden = True
         Case Else
            Rows(RowCnt).Hidden = False
      End Select
   Next RowCnt
End Sub
Thanks so much!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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