Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
SL SL is offline
external usenet poster
 
Posts: 7
Default Find Number of Weeks in a Month

I have a macro that does various things to data in a worksheet. One of the
things I need to be able to do is for each month, find the number of weeks in
that month.

E.g. for April, how many weeks is there in that month - I only have the
month name to go by but I want it to check the number of weeks for April in
the current year.

Thanks

Sonya

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Find Number of Weeks in a Month

try where b2 contains april or apr

=(DATE(YEAR(NOW()),MONTH($B$2&"-0")+1,1)-DATE(YEAR(NOW()),MONTH($B$2&"-0"),1))/7

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"SL" wrote in message
...
I have a macro that does various things to data in a worksheet. One of the
things I need to be able to do is for each month, find the number of weeks
in
that month.

E.g. for April, how many weeks is there in that month - I only have the
month name to go by but I want it to check the number of weeks for April
in
the current year.

Thanks

Sonya


  #3   Report Post  
Posted to microsoft.public.excel.programming
SL SL is offline
external usenet poster
 
Posts: 7
Default Find Number of Weeks in a Month

Thank You - just the ticket

"Don Guillett" wrote:

try where b2 contains april or apr

=(DATE(YEAR(NOW()),MONTH($B$2&"-0")+1,1)-DATE(YEAR(NOW()),MONTH($B$2&"-0"),1))/7

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"SL" wrote in message
...
I have a macro that does various things to data in a worksheet. One of the
things I need to be able to do is for each month, find the number of weeks
in
that month.

E.g. for April, how many weeks is there in that month - I only have the
month name to go by but I want it to check the number of weeks for April
in
the current year.

Thanks

Sonya



  #6   Report Post  
Posted to microsoft.public.excel.programming
SL SL is offline
external usenet poster
 
Posts: 7
Default Find Number of Weeks in a Month



"SL" wrote:

Actually after thinking about it - what I need is the number of Sundays in a
month, which is mostly 4 but occasionally 5.


I found the answer in another thread

=4+(DAY(M2-DAY(M2)+1-WEEKDAY(M2-DAY(M2+7))+35)7)

"Don Guillett" wrote:

When won't it be 4?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"SL" wrote in message
...
Thank You - just the ticket

"Don Guillett" wrote:

try where b2 contains april or apr

=(DATE(YEAR(NOW()),MONTH($B$2&"-0")+1,1)-DATE(YEAR(NOW()),MONTH($B$2&"-0"),1))/7

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"SL" wrote in message
...
I have a macro that does various things to data in a worksheet. One of
the
things I need to be able to do is for each month, find the number of
weeks
in
that month.

E.g. for April, how many weeks is there in that month - I only have the
month name to go by but I want it to check the number of weeks for
April
in
the current year.

Thanks

Sonya





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Find Number of Weeks in a Month

That formula won't give the number of Sundays in a month, assuming you have a
date in M2, any date in the month in question, then this formula will give
you a count of Sundays in that month:

=4+(DAY(M2-DAY(M2)+35)<WEEKDAY(M2-DAY(M2)))

....although you originally said that you would have a cell with the month in
text, so if M2 contains a text representation of the month e.g. Jan or
October then this formula will give you the number of Sundays in that month
in the current year:

=4+(DAY((1&M2)+34)<WEEKDAY((1&M2)+6))





"SL" wrote:



"SL" wrote:

Actually after thinking about it - what I need is the number of Sundays in a
month, which is mostly 4 but occasionally 5.


I found the answer in another thread

=4+(DAY(M2-DAY(M2)+1-WEEKDAY(M2-DAY(M2+7))+35)7)

"Don Guillett" wrote:

When won't it be 4?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"SL" wrote in message
...
Thank You - just the ticket

"Don Guillett" wrote:

try where b2 contains april or apr

=(DATE(YEAR(NOW()),MONTH($B$2&"-0")+1,1)-DATE(YEAR(NOW()),MONTH($B$2&"-0"),1))/7

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"SL" wrote in message
...
I have a macro that does various things to data in a worksheet. One of
the
things I need to be able to do is for each month, find the number of
weeks
in
that month.

E.g. for April, how many weeks is there in that month - I only have the
month name to go by but I want it to check the number of weeks for
April
in
the current year.

Thanks

Sonya





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
How do you calculate the number of weeks on a month Sunnyskies Excel Discussion (Misc queries) 7 April 4th 23 11:23 AM
Find the number of weeks using an array Fred[_8_] Excel Discussion (Misc queries) 0 June 17th 11 05:00 PM
weeks in a month rk0909 Excel Discussion (Misc queries) 1 January 19th 10 04:44 AM
Find the number of days in a month catrrmg Excel Worksheet Functions 2 August 1st 07 12:04 PM
How do I count the number of even weeks in the current month. dd Excel Worksheet Functions 6 February 22nd 07 07:29 AM


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