Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 15
Default delete rows with dates between

Hi,

I have a spreadsheet, column J has dates ranging from June05 - June 06.
I want to delete the entire row if the date falls between 06/01/2005
and 12/31/2005, and merge all the rows up.

I have tried a few things on here but havent gotten them to work for my
situation.

Thank you in advance for any help!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default delete rows with dates between

I've used something like this:

Dim DeleteValue As String
Dim rng As Range

DeleteValue = "File(s)"
' This will delete the rows with "File(s)" in the Range("A2:A65536")
With ActiveSheet
.Range("A2:A65536").AutoFilter Field:=1, Criteria1:="=*File(s)*"
' Need to figure out how to enter DeleteValue above

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete

End With
.AutoFilterMode = False
End With


It could probably be more elegant, but it works.

"dan" wrote:

Hi,

I have a spreadsheet, column J has dates ranging from June05 - June 06.
I want to delete the entire row if the date falls between 06/01/2005
and 12/31/2005, and merge all the rows up.

I have tried a few things on here but havent gotten them to work for my
situation.

Thank you in advance for any help!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default delete rows with dates between


dan skrev:
Hi,

I have a spreadsheet, column J has dates ranging from June05 - June 06.
I want to delete the entire row if the date falls between 06/01/2005
and 12/31/2005, and merge all the rows up.

I have tried a few things on here but havent gotten them to work for my
situation.

Thank you in advance for any help!


Hi dan

This asume you have a header
Sub DeleteRows()

Dim i As Double, lastrow As Double, Mydate As Date, rngDate As Date
lastrow = Cells(Rows.Count, "J").End(xlUp).Row
Mydate = "06/01/2006"
With ActiveSheet
For i = lastrow To 2 Step -1
rngDate = Range("J2").Offset((i - 2), 0).Value
If rngDate < Mydate Then
Range("J2").Offset((i - 2), 0).EntireRow.Delete

End If
Next i
End With

End Sub

Regards Yngve

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
I need to filter and delete rows of information between 2 dates lpdarspe Excel Programming 12 November 16th 06 11:47 PM
Delete rows between two dates jocker Excel Programming 12 December 2nd 05 07:02 PM
Delete Rows whose value is not between 2 dates Dominique Feteau[_2_] Excel Programming 4 March 3rd 05 02:59 PM
Delete rows with particular dates present Mackay 1979 Excel Programming 0 November 4th 04 10:10 AM
Delete Rows with particular dates Al Mackay Excel Programming 3 November 2nd 04 10:14 AM


All times are GMT +1. The time now is 01:46 PM.

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"