Solved

Activate Workbook minus 1 days

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

815 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

11 Experts available now in Live!

Get 1:1 Help Now