hide rows with any dates

A

acarril

I've been using vb to find rows and hide them based on key text. I no
need to hide rows based on a date (they vary). Can someone pleas
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 Su
 
J

JE McGimpsey

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
 
A

acarril

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top