Solved

Open file with changing month

Posted on 2014-07-23
3
104 Views
Last Modified: 2014-07-23
Hi,

I have a file called

Call_Report_June_2014.xlsx

next month it will be

Call_Report_July_2014.xlsx

It will be ran on the 01/08/2014


Can i get some code that recognises the last month, so on 01/08/2014 - it will seek file name

Call_Report_July_2014.xlsx

on the 01/09/2014 it will seek file name

Call_Report_September_2014.xlsx


Many thanks
0
Comment
Question by:Seamus2626
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40213818
Hi,

pls try

thedate = Date - 10 ' 10 instead of 1 as security for holidays
strFile = "Call_Report_" & StrConv(Format(thedate, "MMMM_YYYY"), vbProperCase) & ".xlsx"

Regards
0
 

Author Comment

by:Seamus2626
ID: 40213839
That looks good, that is picking the right file, now how do i open it?

Thanks
0
 

Author Closing Comment

by:Seamus2626
ID: 40213847
Got it

Workbooks.Open (strFile)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

758 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

25 Experts available now in Live!

Get 1:1 Help Now