Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Activate Workbook minus 1 days

Posted on 2011-09-30
2
Medium Priority
?
226 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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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.

927 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