Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete current month using AUTOFILTER


Hi all,

Please can anyone help me with this?

1) I am looking put additional functionality in my current code (below)
to delete rows if value in column A (which is a date in this format
12/31/2005) is the current month.
i.e. if this month is November 2005, delete every row for november
2005-the current month.
How do i add to this code to do that?

2) Also, how do i add to this code to delete duplicate rows in my
sheet? Like if i have two exact dates in column A, delete one and keep
one!

Thanks in advance :)


Code:
--------------------

Worksheets("DataTable").Select
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:=#3/25/2005#, _
Operator:=xlOr, Criteria2:=#12/31/2004#
.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With

--------------------


--
Mslady
------------------------------------------------------------------------
Mslady's Profile: http://www.excelforum.com/member.php...o&userid=27776
View this thread: http://www.excelforum.com/showthread...hreadid=481904

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete current month using AUTOFILTER


Any help or ideas would be great. I particularly need number 1) done,
that takes priority for now ;)
Thanks guys!


--
Mslady
------------------------------------------------------------------------
Mslady's Profile: http://www.excelforum.com/member.php...o&userid=27776
View this thread: http://www.excelforum.com/showthread...hreadid=481904

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete current month using AUTOFILTER

Hi

You can also use EasyFilter to do this
http://www.rondebruin.nl/easyfilter.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Mslady" wrote in message
...

Any help or ideas would be great. I particularly need number 1) done,
that takes priority for now ;)
Thanks guys!


--
Mslady
------------------------------------------------------------------------
Mslady's Profile: http://www.excelforum.com/member.php...o&userid=27776
View this thread: http://www.excelforum.com/showthread...hreadid=481904



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Delete current month using AUTOFILTER

try
Sub fileroutthismonth()
With Worksheets("sheet10")
startday = DateSerial(Year(Date), Month(Date), 1)
stopday = DateSerial(Year(Date), Month(Date) + 1, 1)
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="=" & startday & "", _
Operator:=xlOr, Criteria2:=" & stopday & """
.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub

--
Don Guillett
SalesAid Software

"Mslady" wrote in
message ...

Hi all,

Please can anyone help me with this?

1) I am looking put additional functionality in my current code (below)
to delete rows if value in column A (which is a date in this format
12/31/2005) is the current month.
i.e. if this month is November 2005, delete every row for november
2005-the current month.
How do i add to this code to do that?

2) Also, how do i add to this code to delete duplicate rows in my
sheet? Like if i have two exact dates in column A, delete one and keep
one!

Thanks in advance :)


Code:
--------------------

Worksheets("DataTable").Select
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:=#3/25/2005#, _
Operator:=xlOr, Criteria2:=#12/31/2004#
.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With

--------------------


--
Mslady
------------------------------------------------------------------------
Mslady's Profile:

http://www.excelforum.com/member.php...o&userid=27776
View this thread: http://www.excelforum.com/showthread...hreadid=481904



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Delete current month using AUTOFILTER

actually this would be better.

Sub fileroutthismonth()
With Worksheets("sheet10")
startday = DateSerial(Year(Date), Month(Date), 1)
stopday = DateSerial(Year(Date), Month(Date) + 1, 1)
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="=" & startday & "", _
Operator:=xlAnd, Criteria2:="<" & stopday & ""
.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
try
Sub fileroutthismonth()
With Worksheets("sheet10")
startday = DateSerial(Year(Date), Month(Date), 1)
stopday = DateSerial(Year(Date), Month(Date) + 1, 1)
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="=" & startday & "", _
Operator:=xlOr, Criteria2:=" & stopday & """
.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub

--
Don Guillett
SalesAid Software

"Mslady" wrote in
message ...

Hi all,

Please can anyone help me with this?

1) I am looking put additional functionality in my current code (below)
to delete rows if value in column A (which is a date in this format
12/31/2005) is the current month.
i.e. if this month is November 2005, delete every row for november
2005-the current month.
How do i add to this code to do that?

2) Also, how do i add to this code to delete duplicate rows in my
sheet? Like if i have two exact dates in column A, delete one and keep
one!

Thanks in advance :)


Code:
--------------------

Worksheets("DataTable").Select
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:=#3/25/2005#, _
Operator:=xlOr, Criteria2:=#12/31/2004#
.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With

--------------------


--
Mslady
------------------------------------------------------------------------
Mslady's Profile:

http://www.excelforum.com/member.php...o&userid=27776
View this thread:

http://www.excelforum.com/showthread...hreadid=481904







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete current month using AUTOFILTER


Brilliant!!!
thanks Don! this works perfectly. :)


Code
-------------------
With Worksheets("DataTable")
startday = DateSerial(Year(Date), Month(Date), 1)
stopday = DateSerial(Year(Date), Month(Date) + 1, 1)
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="=" & startday & "", _
Operator:=xlAnd, Criteria2:="<" & stopday & ""
.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
-------------------


Thanks also Ron, for that resource. i have it bookmarked, im sure i
will come in handy.

Thanks guys! :cool

--
Mslad
-----------------------------------------------------------------------
Mslady's Profile: http://www.excelforum.com/member.php...fo&userid=2777
View this thread: http://www.excelforum.com/showthread.php?threadid=48190

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
Current Month Sr Accountant[_2_] Excel Discussion (Misc queries) 1 September 5th 07 03:10 AM
Subtract a future month from the current month to get remaining m. Fletch Excel Worksheet Functions 1 July 26th 07 04:29 PM
Retrieve data for previous 3, 6, 12 month given current month GB Excel Worksheet Functions 4 July 19th 07 11:58 PM
Calculate the first day of the month for the current month? April S. Excel Discussion (Misc queries) 5 July 27th 05 08:53 PM
Current Month Dave M. Excel Programming 5 July 15th 05 03:23 PM


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

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"