View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JoeS JoeS is offline
external usenet poster
 
Posts: 3
Default Macro to Recognize Dates

My code is as follows:

Do Until ActiveCell = ""
Select Case ActiveCell
Case Is = "Print"
ActiveCell.EntireRow.Delete
End Select
ActiveCell.Offset(1, 0).Select
Loop
Range("A1").Select
Do Until ActiveCell = ""
Select Case ActiveCell
Case Is = "Page"
ActiveCell.EntireRow.Delete
End Select
ActiveCell.Offset(1, 0).Select
Loop
Range("A1").Select
Do Until ActiveCell = ""
Select Case ActiveCell
Case Is = "Users"
ActiveCell.EntireRow.Delete
End Select
ActiveCell.Offset(1, 0).Select
Loop
Range("A1").Select
Do Until ActiveCell = ""
Select Case ActiveCell
Case Is = "Status"
ActiveCell.EntireRow.Delete
End Select
ActiveCell.Offset(1, 0).Select
Loop
Range("A1").Select
Do Until ActiveCell = ""
If ActiveCell.Value DateValue("01/10/1901") Then
ActiveCell.EntireRow.Delete
End If
ActiveCell.Offset(1, 0).Select
Loop

I entered the searches one at a time because the words are sometimes
directly below each other and this was the only way I could get it to find
all of the text.

Thanks
--
Joe S


"sebastienm" wrote:

Hi,

You say you are looking for any word Print, Users, Status and Page, and any
dates; i guess you are looping through the entire column cell by cell.

In code how are you checking whether or not the data is a date?
A few ways:

Dim cell as Range, d as Date

Debug.Print typename(cell.value) '---- returns Date?

on error resume next
d=cdate(cell.value)
if err<0 then 'not a date
msgbox "Not a date"
else 'it's a date
'...
end if

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"JoeS" wrote:

Hello.

I am attempting to write a Macro to automate some formatting I do as a
result of an ugly cut and paste into excel from Adobe Acrobat. I have the
manual process down and now I am having trouble automating it. I want the
macro to search column A for the words Print, Users, Status and Page; and any
dates. I then want the macro to delete the entire row. So far I have it
finding and deleting the text okay with a "Case" function. For some reason it
is not finding the dates.

Any ideas?
--
Joe S