ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   hide rows with any dates (https://www.excelbanter.com/excel-programming/304551-re-hide-rows-any-dates.html)

JE McGimpsey

hide rows with any dates
 
One way:

Public Sub SearchAndHide()
Dim rCell As Range
Dim rHide As Range
For Each rCell In Range("A12:A5000")
With rCell
If IsDate(.Value) Then
If rHide Is Nothing Then
Set rHide = .Cells
Else
Set rHide = Union(rHide, .Cells)
End If
End If
End With
Next rCell
If Not rHide Is Nothing Then _
rHide.EntireRow.Hidden = True
End Sub


In article ,
acarril wrote:

I've been using vb to find rows and hide them based on key text. I now
need to hide rows based on a date (they vary). Can someone please
help?
Sub search()
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Range("A12:A5000")
If cell.Value = "RTRSSTCK" Then
cell.EntireRow.Hidden = True
ElseIf cell.Value = 1 Then
cell.EntireRow.Hidden = False
End If
Next
Application.ScreenUpdating = True
End Sub


---
Message posted from http://www.ExcelForum.com/


acarril[_3_]

hide rows with any dates
 
thanks that worked!
how would i re-write the code to delete entire row with either text o
date

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 02:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com