#1   Report Post  
AnitaML
 
Posts: n/a
Default Weeknum Function

Hi

I have two dates, in two columns. One is a start date, and one is a
completion date. What I would like to do is list all of the week numbers that
are included in the range between these two. So for example, if my start date
is 1 January 2005 and my completion date is 21 January 2005, I would like to
display 1, 2, 3.

Is this at all possible?

Many thanks to anyone who can help.
  #2   Report Post  
Junior Member
 
Location: Washington, DC
Posts: 16
Default

Anita,

Let me know if you've never worked with VB Editor before...

Open up the VB Editor (Alt+F11) and go to Tools,References and make sure there's a check next to atpvbaen.xls.

After that, paste in the Function below. Note: if you paste it into a module for the current workbook, the function will only be available in that workbook. If you paste it into a module in "Personal.xls" it will always be available.

Here's the Function:

'-------------------------
Function WeekNumList(Start_Date, End_Date)

Dim Results As String

Start_Weeknum = Weeknum(Start_Date)
End_Weeknum = Weeknum(End_Date)
Results = ""

For i = Start_Weeknum To End_Weeknum - 1
Results = Results & i & ", "
Next

Results = Results & End_Weeknum

WeekNumList = Results

End Function
'-------------------------

Then use the Function as you would any other:

=Weeknumlist(A1,B1)

Knightly

Quote:
Originally Posted by AnitaML
Hi

I have two dates, in two columns. One is a start date, and one is a
completion date. What I would like to do is list all of the week numbers that
are included in the range between these two. So for example, if my start date
is 1 January 2005 and my completion date is 21 January 2005, I would like to
display 1, 2, 3.

Is this at all possible?

Many thanks to anyone who can help.

Last edited by sirknightly : August 23rd 05 at 08:00 PM Reason: Error in Formula
  #3   Report Post  
AnitaML
 
Posts: n/a
Default

Hi

I don't have atpvbaen.xls as an option in my References, they all seem to be
Type Libraries. I pasted the function anyway, but it didn't work. I got the
error message: Sub or Function not defined.

Thanks

Anita

"sirknightly" wrote:


Anita,

Let me know if you've never worked with VB Editor before...

Open up the VB Editor (Alt+F11) and go to Tools,References and make
sure there's a check next to atpvbaen.xls.

After that, paste in the Function below. Note: if you paste it into a
module for the current workbook, the function will only be available in
that workbook. If you paste it into a module in "Personal.xls" it will
always be available.

Here's the Function:

'-------------------------
Function WeekNumList(Start_Date, End_Date)

Dim Results As String

Start_Weeknum = Weeknum(Start_Date)
End_Weeknum = Weeknum(End_Date)
Results = ""

For i = Start_Weeknum To End_Weeknum - 1
Results = Results & i & ", "
Next

Results = Results & End_Weeknum

WeekNumList = Results

End Function
'-------------------------

Then use the Function as you would any other:

=Weeknumlist(A1)

Knightly

AnitaML Wrote:
Hi

I have two dates, in two columns. One is a start date, and one is a
completion date. What I would like to do is list all of the week
numbers that
are included in the range between these two. So for example, if my
start date
is 1 January 2005 and my completion date is 21 January 2005, I would
like to
display 1, 2, 3.

Is this at all possible?

Many thanks to anyone who can help.



--
sirknightly

  #4   Report Post  
AnitaML
 
Posts: n/a
Default

OK

I managed to find it and add it, but now it comes up with my favourite #VALUE!

Any ideas what I'm doing wrong?

Thanks

Anita

"AnitaML" wrote:

Hi

I don't have atpvbaen.xls as an option in my References, they all seem to be
Type Libraries. I pasted the function anyway, but it didn't work. I got the
error message: Sub or Function not defined.

Thanks

Anita

"sirknightly" wrote:


Anita,

Let me know if you've never worked with VB Editor before...

Open up the VB Editor (Alt+F11) and go to Tools,References and make
sure there's a check next to atpvbaen.xls.

After that, paste in the Function below. Note: if you paste it into a
module for the current workbook, the function will only be available in
that workbook. If you paste it into a module in "Personal.xls" it will
always be available.

Here's the Function:

'-------------------------
Function WeekNumList(Start_Date, End_Date)

Dim Results As String

Start_Weeknum = Weeknum(Start_Date)
End_Weeknum = Weeknum(End_Date)
Results = ""

For i = Start_Weeknum To End_Weeknum - 1
Results = Results & i & ", "
Next

Results = Results & End_Weeknum

WeekNumList = Results

End Function
'-------------------------

Then use the Function as you would any other:

=Weeknumlist(A1)

Knightly

AnitaML Wrote:
Hi

I have two dates, in two columns. One is a start date, and one is a
completion date. What I would like to do is list all of the week
numbers that
are included in the range between these two. So for example, if my
start date
is 1 January 2005 and my completion date is 21 January 2005, I would
like to
display 1, 2, 3.

Is this at all possible?

Many thanks to anyone who can help.



--
sirknightly

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
Excel option to store trendline's coefficients in cells for use Miguel Saldana Charts and Charting in Excel 9 June 20th 05 08:45 PM
weeknum function says jan1=week1, mod to first 4 day week needed sam Excel Discussion (Misc queries) 3 June 13th 05 04:05 PM
weeknum function returns name error Unison Mike Excel Worksheet Functions 4 May 24th 05 09:27 PM
Automatically up date time in a cell Mark Excel Discussion (Misc queries) 5 May 12th 05 12:26 AM
Will the Excel WEEKNUM function become ISO 8601 compliant? Gilles Moerdijk Excel Worksheet Functions 3 February 8th 05 07:05 PM


All times are GMT +1. The time now is 09:23 PM.

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"