Filter all years date data and delete except current year

nkashyap3

New Member
Joined
Jun 27, 2019
Messages
24
Office Version
  1. 2010
Platform
  1. Windows
Hi Friend, I need help for filter all years date data and delete except current year

Sheets("1_Clarity_REport").Range("E:E").AutoFilter Field:=5, Operator:=xlOr, _
Criteria1:="<=" & Application.Eoyear(Year, -1), Criteria2:=">" & Application.Eoyear(Year, 0)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Re: need help filter all years date data and delete except current year

wrong code copy
my code is
Dim iYear As String
''''''''''''''''''''Working sheet formatting'''''''''''''''''''''''''''''''''''''''''''''
'Sheets("Working").Select

iYear = "<" & Year(Date)

Set wSheetStart = ActiveSheet
Set rFilterHeads = Range("A1", Range("IV1").End(xlToLeft))

With wSheetStart
.AutoFilterMode = False
rFilterHeads.AutoFilter
strCriteria = (iYear)
If strCriteria = vbNullString Then Exit Sub
rFilterHeads.AutoFilter Field:=5, Criteria1:=strCriteria
End With
 
Upvote 0
Re: need help filter all years date data and delete except current year

Try this:

Code:
Sub Macro8()
    Dim sh As Worksheet
    Set sh = ActiveSheet
    sh.Range("A1").AutoFilter 5, "<01/01/" & Year(Date), xlOr, ">12/31/" & Year(Date)
    sh.AutoFilter.Range.Offset(1).EntireRow.Delete
    sh.ShowAllData
End Sub
 
Upvote 0
Re: need help filter all years date data and delete except current year

Try this:

Code:
Sub Macro8()
    Dim sh As Worksheet
    Set sh = ActiveSheet
    sh.Range("A1").AutoFilter 5, "<01/01/" & Year(Date), xlOr, ">12/31/" & Year(Date)
    sh.AutoFilter.Range.Offset(1).EntireRow.Delete
    sh.ShowAllData
End Sub


Thanks Its working
 
Upvote 0
Re: need help filter all years date data and delete except current year

I'm glad to help you. Thanks for the feedback.
 
Upvote 0
Re: need help filter all years date data and delete except current year

Hi Dente,

can you suggest and help to clear the issue where I am stuck. I have write the vba code in outlook 365 office , my criteria is I have file which is saved in my systems C:\ Drive. I want when I click on butto In outlook , file attached in new mail and send in my team there is 4 person. my code is working on one mail id not on multiple id,

Sub Mail_small_Text_Outlook()
'Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim answer As Integer

Set OutApp =CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)



strbody = "Hi there" &vbNewLine & vbNewLine & _
"PFA"

On Error Resume Next
With OutMail
.To = "nkashyap3@metlife.com"
.CC =""
.BCC =""
.Subject ="text file"
.Body = strbody
.Attachments.Add("C:\CPF\201809_NO_Amnt.txt") 'ou can add a file like this
.Display
answer =MsgBox("Do you want to send an e-mail?", vbYesNo + vbQuestion,"Send Email")
'
If answer = vbYes Then
.Send
Else
Exit Sub
End If
'If MsgBox("Do youwant to send an e-mail?", vbQuestion + vbYesNo, "Send Email") =vb yes Then
'or use
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing



 
Upvote 0
Re: need help filter all years date data and delete except current year

I don't have 365 I suggest you create a new thread.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top