LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Delete Rows whose value is not between 2 dates

I like your way better. Much more elegant.

Glen

"Dave D-C" wrote in message
...
I'm sure Occam would have coded
Sub DeleteDates()
Dim StDate As Date, FinDate As Date, LastRow&, i&
StDate = InputBox("Beginning Date?")
FinDate = InputBox("Ending Date?")
LastRow = Cells(Rows.Count, 5).End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, 5).Value = StDate And _
Cells(i, 5).Value <= FinDate Then
Rows(i).delete
End If
Next i
End Sub

Glen wrote:
One way:
Enter the Start Date in F1 and Finish Date in G1
Then run this macro
Sub DeleteDates()
Dim StDate As Date, FinDate As Date
Dim LastRow As Integer

StDate = Range("F1").Value
FinDate = Range("G1").Value
LastRow = Cells(Rows.Count, 5).End(xlUp).Row
For I = 2 To LastRow
If Cells(I, 5).Value = StDate And Cells(I, 5).Value <= FinDate
Then
Cells(I, 8).Value = "D"
End If
Next

Range("H1").Select
'Note Field:=8 assumes columns A-D have data, otherwise Field could =
4
Selection.AutoFilter Field:=8, Criteria1:="D"
Range("A2:H" & LastRow).Select
Selection.Delete
Selection.AutoFilter
Range("A1").Select
End Sub


Dominique wrote:
I have a report that is imported into excel. I dont need all the data.
Column E has dates. I'd like to delete the rows that arent between 2
dates. for example, when the macro is run, it'll ask me for a beginning
date and a ending date and delete all the rows that dont equal.

any suggestions?



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption
=----





 
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
Hpw do I delete multiple empty rows found between filled rows? Bill Excel Worksheet Functions 2 November 15th 09 07:12 PM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM
Delete rows with particular dates present Mackay 1979 Excel Programming 0 November 4th 04 09:10 AM
Delete Rows with particular dates Al Mackay Excel Programming 3 November 2nd 04 09:14 AM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 08:45 AM.

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

About Us

"It's about Microsoft Excel"