Hi Guys and Girls
This is probably a real easy fix but its got me scratching my head. Have searched the net with no luck.
I have a macro that need to hide a row based on a specific word appearing within the column
So the column in question is column D as per my range in the code (D3:D8000) it needs to look through this column for the word 'shop' and then hide the row if found. The issue is the word shop is not the only word in the D cell (ie Shop Alpha, Shop Bravo) so I need it to recognise the word Shop in the phrase and hide that row.
The code also needs to look for a 2nd word and hide that row aswell (ie Board)
So in this picture example it would hide all rows except those containing Paper
TIA for any help
This is probably a real easy fix but its got me scratching my head. Have searched the net with no luck.
I have a macro that need to hide a row based on a specific word appearing within the column
So the column in question is column D as per my range in the code (D3:D8000) it needs to look through this column for the word 'shop' and then hide the row if found. The issue is the word shop is not the only word in the D cell (ie Shop Alpha, Shop Bravo) so I need it to recognise the word Shop in the phrase and hide that row.
The code also needs to look for a 2nd word and hide that row aswell (ie Board)
So in this picture example it would hide all rows except those containing Paper
TIA for any help
VBA Code:
Sub HideRows()
Dim rCheck As Range
Dim rHide As Range
Dim rCheckCell As Range
Set rCheck = Workbooks("WS TemplateV2.xlsm").Worksheets("3.Shipment details").Range("D3:D8000")
rCheck.EntireRow.Hidden = False
For Each rCheckCell In rCheck.Cells
If InStr(1, rCheckCell, "Shop", vbTextCompare) > 0 Then
If Not rHide Is Nothing Then Set rHide = Union(rHide, rCheckCell) Else Set rHide = rCheckCell
End If
Next rCheckCell
If Not rHide Is Nothing Then rHide.EntireRow.Hidden = True
End Sub