+ Reply to Thread
Results 1 to 5 of 5

Embed Excel Formula in VBA

  1. #1
    Forum Contributor Tarball's Avatar
    Join Date
    04-21-2007
    Location
    Atlanta, GA
    Posts
    166

    Embed Excel Formula in VBA

    I need to calculate the absolute week and have found a formula to do so. Is there a way to embed/execute this in VBA?

    TRUNC(((StartDate-DATE(YEAR(StartDate),1,0))+6)/7) where StartDate is the date which you are trying to find the corresponding week number (for example Now().
    Last edited by Tarball; 12-30-2009 at 04:10 PM.
    Reach me at excel_help at bellsouth dot net

  2. #2
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Office 2003 / Office 2007
    Posts
    114

    Re: Embed Excel Formula in VBA

    Try this:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor Tarball's Avatar
    Join Date
    04-21-2007
    Location
    Atlanta, GA
    Posts
    166

    Re: Embed Excel Formula in VBA

    Thanks but that will not work.
    Please Login or Register  to view this content.
    It appears that the way excel returns the week number is dependent upon when the first day of the week is. A week always begins on a Monday, and the international standards organization defines week 1 as beginning on the Monday of the first week of the year that contains a Thursday. Said differently, week 1 is the first week (beginning on Monday) that has at least four days.

    I need to be able to report the absolute week number. The formula does that but I need it in VBA. I guess I can figure it out in code but was hoping to take the easy way out and just imbed the formula (lazy I know!)

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,292

    Re: Embed Excel Formula in VBA

    You could use:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Contributor Tarball's Avatar
    Join Date
    04-21-2007
    Location
    Atlanta, GA
    Posts
    166

    Re: Embed Excel Formula in VBA

    Well that was too easy! I should have known better. Thank you for the solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1