Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8771811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:53:03+00:00 2026-06-13T17:53:03+00:00

I have a workbook that for example sake we will call Monthly Dashboard, the

  • 0

I have a workbook that for example sake we will call Monthly Dashboard, the information in this is created entirely from a separate workbook named Trial Balance, barring one cell. This data is going to be collected from a weekly workbook called Project Control. Project control files are saved in the format of YYYYWProjectControl.xlsx, where YYYY refers to the current year and W refers to the week.

The cell that needs to be filled is the total sales figure of all projects to date on the weekly form. What I need to do is programatically open the last created project control and take this sales figure out and close/save.

The closing and saving is all completed as part of a previous project but I need to know how to check what the current week number is and to check which the last created file is. Does anyone have any clue how to do this? If so please also bear in mind that with the end of the year approaching that January will need to search for the last created 2013 project control and if there is not one then it will need to search 2012.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:53:04+00:00Added an answer on June 13, 2026 at 5:53 pm

    Depending on whether you are referring to actual week or Fiscal (Financial) week then you can use either of these two functions to calculate for you:

    Fiscal Week:

    Function FiscalWeek(dtDate As Variant)
    
    Dim dtFiscal    As Date
    Dim dtFstMon    As Date
    Dim i           As Integer
    
        'Ensure we are working with a valid date
        If Not IsDate(dtDate) Then
            FiscalWeek = "Invalid Date"
            Exit Function
        End If
    
        'Strip out any timestamps
        dtFiscal = DateSerial(Year(dtDate), Month(dtDate), Day(dtDate))
    
        'Determine first Monday of April for given year
        i = 1
        Do Until Weekday(DateSerial(Year(dtFiscal), 4, i), 2) = 1
            i = i + 1
        Loop
    
        dtFstMon = DateSerial(Year(dtFiscal), 4, i)
    
        'Work out the difference in weeks from April for the relevant year
        Select Case dtFiscal
            Case Is < dtFstMon
                FiscalWeek = DateDiff("WW", DateSerial(Year(dtFiscal) - 1, 4, 1), dtFiscal, 2)
            Case Else
                FiscalWeek = DateDiff("WW", DateSerial(Year(dtFiscal), 4, 1), dtFiscal, 2) + IIf(i = 1, 1, 0)
        End Select
    
    End Function
    

    Or Actual Week:

    Function ActualWeek(dtDate As Variant)
    
    Dim dtActual    As Date
    Dim dtFstMon    As Date
    Dim i           As Integer
    
        'Ensure we are working with a valid date
        If Not IsDate(dtDate) Then
            ActualWeek = "Invalid Date"
            Exit Function
        End If
    
        'Strip out any timestamps
        dtActual = DateSerial(Year(dtDate), Month(dtDate), Day(dtDate))
    
        'Determine first Monday of January for given year
        i = 1
        Do Until Weekday(DateSerial(Year(dtActual), 1, i), 2) = 1
            i = i + 1
        Loop
    
        dtFstMon = DateSerial(Year(dtActual), 1, i)
    
        'Work out the difference in weeks from January for the relevant year
        Select Case dtActual
            Case Is < dtFstMon
                ActualWeek = DateDiff("WW", DateSerial(Year(dtActual) - 1, 1, 1), dtActual, 2)
            Case Else
                ActualWeek = DateDiff("WW", DateSerial(Year(dtActual), 1, 1), dtActual, 2) + IIf(i = 1, 1, 0)
        End Select
    
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some vba code that selects a range from a workbook and
I don't know if this is possible or not. I have a workbook that
I currently have a excel workbook that has values being pulled from other workbooks
I have a workbook that has many checkboxes (form control) on one tab. I
I have an Excel workbook that I want to use as a template. It
I have an Excel Workbook that has several worksheets in it. The tables in
So I have an excel workbook that has a nice global map of shaperange
I have a VSTO Excel workbook that functions correctly in test. I can deploy
I have an excel 2003 vsto workbook that I would like to make available
I have an excel workbook vsto solution that needs to generate a pdf copy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.