Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KUS KUS is offline
external usenet poster
 
Posts: 2
Default Getting the Kalendar Week within VBA

Hi all,

within an actual project i need VBA to deliver the calendar week,
corresponding to a date.

If there´s a worksheet function able to do the job this will do instead,
naturally.

Thanks a lot in advance!

--
Kai
Cologne, Germany

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting the Kalendar Week within VBA


Take a look at the WEEKNUM Function, I can't remember if it is part of
the Analysis ToolPak which needs to be added from your Office CD. These
Functions are now built in in Excel 2007

=WEEKNUM(A1) where the date is in A1

=WEEKNUM(TODAY())


--
royUK

Hope that helps.

RoyUK
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=26892

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Getting the Kalendar Week within VBA

Use the standard Excel function WEEKNUM perhaps?

--

Regards,
Nigel




"KUS" wrote in message
...
Hi all,

within an actual project i need VBA to deliver the calendar week,
corresponding to a date.

If there´s a worksheet function able to do the job this will do instead,
naturally.

Thanks a lot in advance!

--
Kai
Cologne, Germany


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Getting the Kalendar Week within VBA

Hi,

Requires analysis toolpak
=WEEKNUM(A1)

without analysis toolpak
=INT((A1-DATE(YEAR(A1),1,1))/7)+1


ISO week mumber
=INT((A1-WEEKDAY(A1,2)-DATE(YEAR(A1+4-WEEKDAY(A1,2)),1,4))/7)+2


or in VB
wk = DatePart("ww", "8/11/2008")

Mike

"KUS" wrote:

Hi all,

within an actual project i need VBA to deliver the calendar week,
corresponding to a date.

If there´s a worksheet function able to do the job this will do instead,
naturally.

Thanks a lot in advance!

--
Kai
Cologne, Germany


  #5   Report Post  
Posted to microsoft.public.excel.programming
KUS KUS is offline
external usenet poster
 
Posts: 2
Default Getting the Kalendar Week within VBA


...thanks a lot for your speedy and most useful hints!

Since the toolpak configuration on the clients´machines is not unified (and
undocumented),
i will try the non-poolpak-VBSolution (works greatly fast).

Yours sincerely,

Kai
Colgone, Germany



"Mike H" wrote in message
...
Hi,

Requires analysis toolpak
=WEEKNUM(A1)

without analysis toolpak
=INT((A1-DATE(YEAR(A1),1,1))/7)+1


ISO week mumber
=INT((A1-WEEKDAY(A1,2)-DATE(YEAR(A1+4-WEEKDAY(A1,2)),1,4))/7)+2


or in VB
wk = DatePart("ww", "8/11/2008")

Mike

"KUS" wrote:

Hi all,

within an actual project i need VBA to deliver the calendar week,
corresponding to a date.

If there´s a worksheet function able to do the job this will do instead,
naturally.

Thanks a lot in advance!

--
Kai
Cologne, Germany




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Getting the Kalendar Week within VBA

Kai

Beware!!! Germany, like most of Europe, uses the ISO week system. When
January 1st is on a friday, saturday or sunday those systems are one week
different.

So if you use WEEKNUM or similar now, it will look pretty fine until 2010,
when it starts returning a wrong value and nobody understands why it
suddenly fails.

See http://www.rondebruin.nl/weeknumber.htm for more on this.

HTH. Best wishes Harald


"KUS" wrote in message
...

..thanks a lot for your speedy and most useful hints!

Since the toolpak configuration on the clients´machines is not unified
(and undocumented),
i will try the non-poolpak-VBSolution (works greatly fast).

Yours sincerely,

Kai
Colgone, Germany



"Mike H" wrote in message
...
Hi,

Requires analysis toolpak
=WEEKNUM(A1)

without analysis toolpak
=INT((A1-DATE(YEAR(A1),1,1))/7)+1


ISO week mumber
=INT((A1-WEEKDAY(A1,2)-DATE(YEAR(A1+4-WEEKDAY(A1,2)),1,4))/7)+2


or in VB
wk = DatePart("ww", "8/11/2008")

Mike

"KUS" wrote:

Hi all,

within an actual project i need VBA to deliver the calendar week,
corresponding to a date.

If there´s a worksheet function able to do the job this will do instead,
naturally.

Thanks a lot in advance!

--
Kai
Cologne, Germany



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,344
Default Getting the Kalendar Week within VBA

Hi,

One other consideration may be that to use the Analysis ToolPak functions in
the VBE you need to attach the Analysis ToolPak - VBA. And then you need to
reference it - in the VBE choose Tools, References, and put a check beside
atpvbaen.xls.

--
Thanks,
Shane Devenshire


"KUS" wrote:

Hi all,

within an actual project i need VBA to deliver the calendar week,
corresponding to a date.

If there´s a worksheet function able to do the job this will do instead,
naturally.

Thanks a lot in advance!

--
Kai
Cologne, Germany


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
Convert regular Date to Week Ending or Week Beginning Dates Sam H Excel Discussion (Misc queries) 5 April 3rd 23 04:39 PM
Auto calculate day of week to week of the year (not as serial) oftenconfused Excel Discussion (Misc queries) 4 June 23rd 08 05:14 PM
group sales by week and week number Wanna Learn Excel Discussion (Misc queries) 7 November 7th 06 11:44 AM
How do I set up a week by week skill training schedule in excel? davidwatts Excel Discussion (Misc queries) 0 June 16th 05 11:32 PM
I need week number in excell from a date, first week must be mini. jPeich Excel Discussion (Misc queries) 4 January 5th 05 01:21 AM


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