code to find dates
Instead of looking for a string, look for a variant:
Sub FindIt()
Dim rngFind As Range
Dim varFind As Variant
varFind = DateSerial(1997, 5, 1)
Set rngFind = Rows(1).Find(What:=varFind, _
After:=Range("A1"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
Range("C1", rngFind.Offset(, -1)).EntireColumn.Hidden = True
End Sub
--
Dianne
In ,
David typed:
Dim myFind As Range
Set myFind = Rows(1).Find(What:="5/1/1997", _
After:=Range("A1"), _
LookIn:=xlFormulas _
, LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
Range("C1", myFind.Offset(, -1)).EntireColumn.Hidden = True
Changing the "5/1/1997" to "01/05/1997" etc. has no effect
(myFind =Nothing, still) Changing to "May-97" and changing
argument xlformulas to xlvalues works OK but is inflexible
and puts me at the mercy of the cell formatting. What is
the secret with dates?
David
|