Ask your question

Macro

cool - Oct 16, 2009 3:08pm BST - Last answer on Oct 17, 2009 3:29am BST venkat1926
Hello,

I wanted to create an application. I have a sheet "sheet1".there are 3 columns namely name, author and date.
A B C
1 Name Author Date
2 harry Harry 7/2/2009
3 Tom Moody 8/2/2009

Condition is as below:
If the system time is between 9:00 a.m to 5:00 p.m and name is "harry", I have to delete that rows. else i wanted to delete all rows..

Please advise.Configuration: Windows XP Internet Explorer 6.0
Add comment

Other content from Kioskea on « Macro »

Macro, Range SelectionForumOffice software
Macro for deleting row with conditionForumOffice software
Excel search macroForumOffice software
Macros for BeginnersForumOffice software
Copy entire row from one tab into anotherForumOffice software
Help using Excel Macro To Insert RowsForumOffice software
Sort by :   Votes | Date | Date descending 1 answers
+0
moins plus
your second condition is dangerous because you will lose the data. so better copy sheet 1 in sheet 2 and the run this macro

do this experiment only on a sample data first.

Sub test()
Dim r As Range, cfind As Range, tt
Worksheets("sheet1").Select
Set r = Range(Range("a2"), Range("A2").End(xlDown))
With r
Set cfind = .Cells.Find(what:="harry", lookat:=xlWhole)
End With
tt = TimeValue(Now)
MsgBox tt
If tt >= TimeValue("9:00 am") And tt <= TimeValue("5:00 pm") Then
cfind.EntireRow.Delete
Else
r.EntireRow.Delete
End If
End Sub
Add comment