Solved

Activate Workbook minus 1 days

Posted on 2011-09-30
2
207 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

820 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