Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Filter date by month and year

I have a column of dates that I am trying to filter on just the month
and year.

Date
22/05/1981
16/03/1981
26/01/2006
01/05/1986

Is it possible to filter on only the last 4 digits of a cell?

Thanks,

Peter

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Filter date by month and year

Hi Peter

You can insert a helper column with the worksheet function Year or Month
Or install EasyFilter
http://www.rondebruin.nl/easyfilter.htm

Or use advancedfilter, you only have to have one cell with the formula and use that cell in your criteria.


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Peter" wrote in message oups.com...
I have a column of dates that I am trying to filter on just the month
and year.

Date
22/05/1981
16/03/1981
26/01/2006
01/05/1986

Is it possible to filter on only the last 4 digits of a cell?

Thanks,

Peter

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Filter date by month and year

On 6 Feb, 10:02, "Ron de Bruin" wrote:
Hi Peter

You can insert a helper column with the worksheet function Year or Month
Or install EasyFilterhttp://www.rondebruin.nl/easyfilter.htm

Or use advancedfilter, you only have to have one cell with the formula and use that cell in your criteria.

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"Peter" wrote in ooglegroups.com...
I have a column of dates that I am trying to filter on just the month
and year.


Date
22/05/1981
16/03/1981
26/01/2006
01/05/1986


Is it possible to filter on only the last 4 digits of a cell?


Thanks,


Peter- Hide quoted text -


- Show quoted text -


Thank you but I am actually trying to tell the macro to look at the
last 7 digits of a cell and filter it by that. Is this possible?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Filter date by month and year

Yes with advanced file you can use this for Feb 2007

=AND(YEAR(A2)= 2007,MONTH(A2)=2)

A1 is the header cell and a2 is the first date
See Debra's site for more info
http://www.contextures.com/xladvfilter02.html

Easyfilter is much easier


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Peter" wrote in message ups.com...
On 6 Feb, 10:02, "Ron de Bruin" wrote:
Hi Peter

You can insert a helper column with the worksheet function Year or Month
Or install EasyFilterhttp://www.rondebruin.nl/easyfilter.htm

Or use advancedfilter, you only have to have one cell with the formula and use that cell in your criteria.

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"Peter" wrote in ooglegroups.com...
I have a column of dates that I am trying to filter on just the month
and year.


Date
22/05/1981
16/03/1981
26/01/2006
01/05/1986


Is it possible to filter on only the last 4 digits of a cell?


Thanks,


Peter- Hide quoted text -


- Show quoted text -


Thank you but I am actually trying to tell the macro to look at the
last 7 digits of a cell and filter it by that. Is this possible?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Filter date by month and year

Oops you want a macro

Record a macro when you do this and insert the formula in the criteria cell with code


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Peter" wrote in message ups.com...
On 6 Feb, 10:02, "Ron de Bruin" wrote:
Hi Peter

You can insert a helper column with the worksheet function Year or Month
Or install EasyFilterhttp://www.rondebruin.nl/easyfilter.htm

Or use advancedfilter, you only have to have one cell with the formula and use that cell in your criteria.

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"Peter" wrote in ooglegroups.com...
I have a column of dates that I am trying to filter on just the month
and year.


Date
22/05/1981
16/03/1981
26/01/2006
01/05/1986


Is it possible to filter on only the last 4 digits of a cell?


Thanks,


Peter- Hide quoted text -


- Show quoted text -


Thank you but I am actually trying to tell the macro to look at the
last 7 digits of a cell and filter it by that. Is this possible?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Filter date by month and year

Sorry Ron, I'm a bit new to this.

Is "=AND(YEAR(A2)= 2007,MONTH(A2)=2) " the code?


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Filter date by month and year

Sorry Ron, I've tried recording the macro. It still doesn't make
sence. What is the code meant to look like?
BTY I really appreciate your help, this has been bugging me for days!

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Filter date by month and year

I will post a example Peter

The filter year and month are they in a worksheet cell or always the same ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Peter" wrote in message oups.com...
Sorry Ron, I've tried recording the macro. It still doesn't make
sence. What is the code meant to look like?
BTY I really appreciate your help, this has been bugging me for days!

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Filter date by month and year

The operator selects the month and the year from 2 list boxes on a
userform.
This is then turned into two variables.

I hope this makes sense, and thanks again!

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Filter date by month and year

Hi Peter

Try this tester

Header in A6:C6
Dates in A7:A1000
data in B7:C1000

We use A1:A2 for the criteria
A1= always empty
a2 = the code insert the formula in this cell

On the user form ListBox2 = years and ListBox2 = months
Note: numbers and not Jan, Feb
If you want that you can use the index

The try this button on the userform


Private Sub CommandButton1_Click()

Range("A2").Formula = "=AND(YEAR(A7)= " & Me.ListBox2.Value & ",MONTH(A7)=" & Me.ListBox1.Value & ")"

Range("A6:C1000").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("A1:A2"), Unique:=False

End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Peter" wrote in message oups.com...
The operator selects the month and the year from 2 list boxes on a
userform.
This is then turned into two variables.

I hope this makes sense, and thanks again!

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
Date(Year,Month,Day) not returnign correct date jlclyde Excel Discussion (Misc queries) 8 October 16th 09 02:42 PM
count month when date is in day/month/year format ccKennedy Excel Worksheet Functions 6 April 30th 09 03:32 AM
=DATE(YEAR(P4),MONTH(P4)+1,1) [email protected] Excel Worksheet Functions 3 January 22nd 09 04:37 PM
Tell me which "season" (Month/Day through Month/Day) a date(Month/Day/Year) falls in (any year)??? misscrf Excel Discussion (Misc queries) 1 December 14th 07 02:59 PM
Sort month/date/year data using month and date only SMW820 Excel Discussion (Misc queries) 6 June 22nd 06 05:14 PM


All times are GMT +1. The time now is 06:15 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"