JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for EXCEL-VB-DISCUSS Archives


EXCEL-VB-DISCUSS Archives

EXCEL-VB-DISCUSS Archives


EXCEL-VB-DISCUSS@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

EXCEL-VB-DISCUSS Home

EXCEL-VB-DISCUSS Home

EXCEL-VB-DISCUSS  June 2002

EXCEL-VB-DISCUSS June 2002

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Week Numbers

From:

Loughins Stephen <[log in to unmask]>

Reply-To:

A list to stimulate discussion about the technical aspects of the developme <[log in to unmask]>

Date:

Tue, 25 Jun 2002 09:47:13 +0100

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (307 lines)

**********************************************************************

This document should only be read by those persons to whom
it is addressed,  and its contents are private and confidential.
If you receive this email message in error, notify the sender
immediately and do not disclose, copy or distribute this message,
or open any attachments.

**********************************************************************

Thanks Matthew

I wasn't sure how to reference an add-in in VB code, I could only create the
application object. I think I've got a work around for my current problem
but this will come in useful in the future.

Stephen

-----Original Message-----
From: [log in to unmask]
[mailto:[log in to unmask]]
Sent: 25 June 2002 09:03
To: [log in to unmask]
Subject: Re: Week Numbers


Stephen

Here's a post I made to VISBAS-L a while back, it might help you, what
issues with VB-Excel are you having?


>>>>>>>snip>>>>>>>>>
Date:         Tue, 24 Apr 2001 02:11:54 -0400
Reply-To:     Visual Basic List <[log in to unmask]>
Sender:       Visual Basic List <[log in to unmask]>
From:         Matthew Inns <[log in to unmask]>
Subject:      Re: How to use Excel 2000 Addin With VB
Ali

Start a new project, make a reference to Excel and add a form, with one
command button, then paste this code in:

'Make a reference to the Excel object library (Excel9.olb)

    Dim objXlApp As Excel.Application
    Dim objWBook As Excel.Workbook
    Dim objATPack As Excel.AddIn

Private Sub Command1_Click()
    Dim dteSettlement As Date
    Dim dteMaturity As Date
    Dim dteIssue As Date
    Dim lngRate As Long
    Dim lngValue As Long

    On Error GoTo BAIL
    'Launch Excel
    Set objXlApp = New Excel.Application
    Set objWBook = objXlApp.Workbooks.Add

    ' Addins need to loaded manually
    objXlApp.AddIns.Add FileName:=objXlApp.LibraryPath
& "\analysis\analys32.xll"
    Set objATPack = objXlApp.AddIns.Item("Analysis ToolPak")
    'and registered
    objXlApp.RegisterXLL "Analys32.xll"

    'analysis tool pack has an automation interface called analysis
toolpack - vba addin
    objXlApp.Workbooks.Open objXlApp.LibraryPath & "\analysis\atpvbaen.xla"
    objXlApp.Workbooks("atpvbaen.xla").RunAutoMacros 1

    dteSettlement = CDate("15/08/99")
    dteMaturity = CDate("15/08/01")
    dteIssue = CDate("12/08/70")
    lngRate = 15
    lngValue = 55
    'run the function from the addin
    MsgBox objXlApp.Application.Run("atpvbaen.xla!yieldmat", dteSettlement,
dteMaturity, dteIssue, lngRate, lngValue)

BAIL:
On Error Resume Next
    'quit excel
    objXlApp.Quit
    Set objATPack = Nothing
    Set objWBook = Nothing
    Set objXlApp = Nothing
End Sub


>>>>>>>>>snip>>>>>>>>

Regards

Matthew Inns
IS Infrastructure Programme Controller
Office: 01189 393739 (33739)
Mobile: 07747 642373 (42373)
http://www.givewater.org




                    Loughins Stephen
                    <Stephen.Loughins@GALLAH       To:
[log in to unmask]
                    ERLTD.COM>                     cc:
                    Sent by: A list to             Subject:     Re: Week
Numbers
                    stimulate discussion
                    about the technical
                    aspects of the
                    developme
                    <EXCEL-VB-DISCUSS@JISCMA
                    IL.AC.UK>


                    25/06/2002 09:03
                    Please respond to A list
                    to stimulate discussion
                    about the technical
                    aspects of the
                    developme






**********************************************************************

This document should only be read by those persons to whom
it is addressed,  and its contents are private and confidential.
If you receive this email message in error, notify the sender
immediately and do not disclose, copy or distribute this message,
or open any attachments.

**********************************************************************

You were right Norman - I had another problem but not the one you
anticipated. I was actually trying to incorporate WeekNum into a VB program
but I can't reference atpvbaen in my project. My solution has been to add a
(hidden) MonthView control and derive week number from it. I wasn't aware
of
the ISO standards for week numbering so thanks for the pointer in that
direction. As an aside if I get any time I'll try coming up with a UDF, I
think I may have written something some time ago which may not be ISO
compliant but I could try to update.

Thanks

Stephen

-----Original Message-----
From: Norman Harker [mailto:[log in to unmask]]
Sent: 25 June 2002 00:27
To: [log in to unmask]
Subject: Re: Week Numbers


Hi Stephen and All!

Anyone got an ISO compliant UDF? WEEKNUM is non-compliant.

We need one that provides week numbers based on week 1 starts on Monday
of the week that contains the first Thursday. Alternative algorithm is
week 1 starts on the Monday of the week that contains January 4th.

TIA

Norman Harker

"Technical appendix:"

Now for the full story!

Excuse me for butting in but I'm anticipating Stephen's next problem and
to point out that WEEKNUM carries a health warning!

See the Help for WEEKNUM in Excel and you will see that there are two
options for return_type.

1 (default) Week begins on Sunday
2 week begins on Monday

ISO 8601 1988 and revised draft 1998 provide that Monday = 1. I'm not
sure what current status of 1998 revised draft is but there were no
changes to week numbering between 1998 Standard and the 1998 revised
draft.

However, ISO week numbers provision is that week 1 is starts on the
first day of the week containing the first Thursday of the calendar
year. Thus if Jan 1st **** is a Thursday then week 1 begins 29 Dec ****
- 1 (i.e. the last Monday of previous year). If Jan 1st is a Friday week
1 begins Jan 7th ****.

Alternative definition (referred to in ISO 8601) is to say that Week 1
is the week, starting on a Monday, that includes 4th January.

What does WEEKNUM do? It doesn't tell you in Excel Help (surprise!). But
by testing it over the "cusp" of a year you will see that 1st January is
always start of week 1 with week 2 starting the following Sunday
(return_type = 1) or Monday (return_type = 2).

That gives you three options!

Use WEEKNUM with return_type = 1 (not ISO compliant).
Use WEEKNUM with return_type = 2 (not ISO compliant).
Create a UDF that complies.

Sees Ya!





> -----Original Message-----
> From: A list to stimulate discussion about the technical
> aspects of the developme
> [mailto:[log in to unmask]] On Behalf Of Loughins Stephen
> Sent: Monday, June 24, 2002 09:17 PM
> To: [log in to unmask]
> Subject: Re: Week Numbers
>
>
> **********************************************************************
>
> This document should only be read by those persons to whom
> it is addressed,  and its contents are private and
> confidential. If you receive this email message in error,
> notify the sender immediately and do not disclose, copy or
> distribute this message, or open any attachments.
>
> **********************************************************************
>
> Hi again Martin
>
> I think I've just found it by creation a reference to "atpvbaen.xls"
>
> Thanks
>
> Stephen
>
> -----Original Message-----
> From: Rushton, Martin [LIS] [mailto:[log in to unmask]]
> Sent: 24 June 2002 11:59
> To: [log in to unmask]
> Subject: Re: Week Numbers
>
>
> The function is weeknum.  I think its part of the analysis pack add-in
>
> > -----Original Message-----
> > From: Loughins Stephen [SMTP:[log in to unmask]]
> > Sent: Monday, June 24, 2002 11:48 AM
> > To:   [log in to unmask]
> > Subject:      Week Numbers
> >
> >
> **********************************************************************
> >
> > This document should only be read by those persons to whom
> > it is addressed,  and its contents are private and confidential. If
> > you receive this email message in error, notify the sender
> immediately
> > and do not disclose, copy or distribute this message, or open any
> > attachments.
> >
> >
> **********************************************************************
> >
> > 'Morning All
> >
> > Is there an Excel function to calculate the week number of a given
> > date?
> >
> > For instance if I provide a date of say 27th May can Excel
> tell me its
> > Week22? I can do it in code but if there's a simple
> function it would
> > be so much easier.
> >
> > TIA
> >
> > Stephen
>




______________________________________________________________________
 Thames Water Plc., Registered Office 14 Cavendish Place, London W1G 9NU.
Registered No. 2366623
This e-mail is confidential and intended solely for the use of the
individual to whom it is
addressed.  Any views or opinions presented are solely those of the author
and do not
necessarily represent those of Thames Water or its subsidiaries.
If you have received this e-mail message in error, please phone our
Computer Service Desk
on +44 (0)118 959 3587.  Please also destroy and delete the message from
your computer.

For more information on Thames Water visit our web site at
www.thames-water.com

Top of Message | Previous Page | Permalink

JISCMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

February 2012
November 2011
October 2011
September 2011
July 2011
June 2011
April 2011
March 2011
February 2011
August 2010
June 2010
May 2010
January 2010
November 2009
September 2009
August 2009
July 2009
January 2009
September 2008
August 2008
July 2008
June 2008
May 2008
March 2008
February 2008
January 2008
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
January 2001
December 2000
November 2000
October 2000
September 2000
August 2000
July 2000
June 2000
May 2000
April 2000
March 2000
February 2000
January 2000
December 1999
November 1999
October 1999
September 1999
August 1999
July 1999
June 1999
May 1999
April 1999
March 1999
February 1999
January 1999
December 1998
November 1998
October 1998
September 1998
August 1998
July 1998
June 1998
May 1998
April 1998
March 1998


WWW.JISCMAIL.AC.UK

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager