Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 199
Default Formula for cells containing last month's date

I have an Excel spreadsheet which includes a column containing dates.

I am trying to create a formula which will tell me the number of cells in
the column that have dates from last month. For some unknown reason I am
having great difficulty with this - even before trying to ensure the formula
will cope with the December/January issue, when the 'month-1' principle
presumably will not work.

Can anyone help please?

Thanks,

V

  #2   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Formula for cells containing last month's date

assuming your dates are in A1:A7 and todays date is in cell C1, try:

=SUMPRODUCT(--(TEXT(A1:A7,"mmyy")=TEXT(C1-DAY(C1),"mmyy")))


"Victor Delta" wrote:

I have an Excel spreadsheet which includes a column containing dates.

I am trying to create a formula which will tell me the number of cells in
the column that have dates from last month. For some unknown reason I am
having great difficulty with this - even before trying to ensure the formula
will cope with the December/January issue, when the 'month-1' principle
presumably will not work.

Can anyone help please?

Thanks,

V


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 199
Default Formula for cells containing last month's date

"JMB" wrote in message
...
assuming your dates are in A1:A7 and todays date is in cell C1, try:

=SUMPRODUCT(--(TEXT(A1:A7,"mmyy")=TEXT(C1-DAY(C1),"mmyy")))


JMB

Many thanks. Works brilliantly!

However, the only thing I don't understand is the two hyphens at the start
of the first bracket?

Regards,

V

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 903
Default Formula for cells containing last month's date

"Victor Delta" wrote in message ...
"JMB" wrote in message
...
assuming your dates are in A1:A7 and todays date is in cell C1, try:

=SUMPRODUCT(--(TEXT(A1:A7,"mmyy")=TEXT(C1-DAY(C1),"mmyy")))


JMB

Many thanks. Works brilliantly!

However, the only thing I don't understand is the two hyphens at the start
of the first bracket?


Two minus at the front convert text to numeric, such as making a number text value negative
then positive.
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 199
Default Formula for cells containing last month's date

"David McRitchie" wrote in message
...
"Victor Delta" wrote in message
...
"JMB" wrote in message
...
assuming your dates are in A1:A7 and todays date is in cell C1, try:

=SUMPRODUCT(--(TEXT(A1:A7,"mmyy")=TEXT(C1-DAY(C1),"mmyy")))


JMB

Many thanks. Works brilliantly!

However, the only thing I don't understand is the two hyphens at the
start of the first bracket?


Two minus at the front convert text to numeric, such as making a number
text value negative
then positive.


Many thanks,

V



  #6   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Formula for cells containing last month's date

David is correct, but the double minus also converts true/false values to 1
and 0 respectively. This allows you to sum the true/false values and get a
count of how many trues there were.

Bob Phillips has an excellent discussion on sumproduct here
http://xldynamic.com/source/xld.SUMPRODUCT.html

"Victor Delta" wrote:

"JMB" wrote in message
...
assuming your dates are in A1:A7 and todays date is in cell C1, try:

=SUMPRODUCT(--(TEXT(A1:A7,"mmyy")=TEXT(C1-DAY(C1),"mmyy")))


JMB

Many thanks. Works brilliantly!

However, the only thing I don't understand is the two hyphens at the start
of the first bracket?

Regards,

V


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 199
Default Formula for cells containing last month's date

"JMB" wrote in message
...
David is correct, but the double minus also converts true/false values to
1
and 0 respectively. This allows you to sum the true/false values and get
a
count of how many trues there were.

Bob Phillips has an excellent discussion on sumproduct here
http://xldynamic.com/source/xld.SUMPRODUCT.html


Thanks for that.

To be honest, I had not come across the Excel sumproduct function before. It
looks very powerful so I will enjoy reading this interesting article.

V

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
divide a month's target into weeks Shazzer Excel Discussion (Misc queries) 4 July 27th 07 02:26 PM
Finding this month's cell Victor Delta Excel Worksheet Functions 5 February 3rd 07 08:46 PM
PivotTable contains last month's dates [email protected] Excel Discussion (Misc queries) 1 August 15th 06 12:32 AM
Finding the most recent month's (or whatever) data Dallman Ross Excel Discussion (Misc queries) 10 July 1st 06 09:19 PM
Pull Current Month's Data Out of List - Repost Karl Burrows Excel Discussion (Misc queries) 4 May 3rd 05 01:06 AM


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