Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default delete based on date in input box

Public Sub ProcessData()
Const TEST_COLUMN As String = "I" '<=== change to suit
Dim i As Long
Dim iLastRow As Long
Dim myDate

With ActiveSheet

myDate = InputBox("Input date")
If Not IsDate(myDate) Then
MsgBox "Invalid date"
Exit Sub
End If
iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).row
For i = iLastRow To 1 Step -1
If .Cells(i, TEST_COLUMN).Value < myDate Then
.Rows(i).Delete
End If
Next i

End With

End Sub

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Light" wrote in message
...
I have written a macro to delete the row if cell I < 19.12.2006

I have two problems. To get my macro to work, I've had to use the
numerical
value for 19th Dec 39070 and I'd much prefer to use 19.12.2006 or similar.

The second problem is that this date will change, so next time I run the
macro I might want the date 30.12.2006. Is there a way of getting a pop-up
box to enter my date in and the macro using this date?

I'd be very grateful if anyone could point me in the right direction
Thanks!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete rows based on date PMBO Excel Discussion (Misc queries) 4 February 18th 09 01:50 PM
input a date or update it based on date in another cell Doug P New Users to Excel 1 July 18th 07 11:25 PM
Data input based on date list? PatrickJ Excel Worksheet Functions 3 February 1st 07 02:20 PM
Recording Time & Date based on data input Lady Success Excel Worksheet Functions 2 October 19th 06 01:51 PM
Select sheet based on userform date input mugitty Excel Programming 4 January 22nd 06 09:37 PM


All times are GMT +1. The time now is 01:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"