Solved

Activate Workbook minus 1 days

Posted on 2011-09-30
2
180 Views
Last Modified: 2012-05-12
I have some code attached that allows me to activate a spreadsheet that has a date of minus 2 days, i am looking for an amendment. First that it activates the spreadsheet minus 1 day and secondly the name of the spreadsheet changed.

It will always be

Sophis Fiscal ddmmyyyy.xls

So if it can look for the spreadsheet Sophis Fiscal ddmmyyyy.xls which has a date of minus 1 day, that would solve my issue!

Thanks
Seamus

Sub ActivateWB()




Dim UseDate As Date

Select Case Weekday(Now)
    Case 1, 4, 5, 6, 7
        UseDate = Date - 2
    Case Else
        UseDate = Date - 4
End Select

Windows("UnmatchedReport_GL_8455_56_57_" & Format(UseDate, "yyyymmdd") & _
    "_TLM2.xls.xls").Activate



End Sub

Open in new window

0
Comment
Question by:Seamus2626
2 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 36890811
Seamus - not entirely sure about the logic there, but try this:
Sub ActivateWB()

Dim UseDate As Date

Select Case Weekday(Now)
    Case 3, 4, 5, 6, 7
        UseDate = Date - 1
    Case Else
        UseDate = Date - 3
End Select

Windows("Sophis Fiscal " & Format(UseDate, "yyyymmdd") & ".xls").Activate

End Sub

Open in new window

0
 

Author Closing Comment

by:Seamus2626
ID: 36890828
Perfect Stephen!!

Thanks
Seamus
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now