Donate SIGN UP

Excel Visual Basic For Apps Help Req.

Avatar Image
Nils | 08:21 Sat 18th May 2013 | Technology
2 Answers
Any VBA experts on here to aswer what I think is a simple question but one I cannot get my head round to get the right answer.

I have written a simple macro to import a couple of sheets from another workbook into another open workbook. I want to then close the original workbook, in the script below it is referred to as 'Dashboard.xlsx'. This file is opened using a variable I've called myFile as the file to be opened each day will not be the same name. So the macro currently fails at this line in the script:

Windows("Dashboard.xlsx").Activate

As the new files are named sequentially each day.


Here's the current script:

myFile = Application.GetOpenFilename()
Workbooks.Open Filename:=myFile
Sheets (Array("Raw OpenWIP Data")).Select
Sheets (Array("Raw OpenWIP Data")).Copy Before:=Workbooks_("Import").Sheets(1)
Windows("Dashboard.xlsx").Activate
ActiveWorkbook.Close SaveChanges:=False


This is probably a very simple questyion but one that is stumping me s've not used VBA for 10 years or so.

Thanks.
Gravatar

Answers

1 to 2 of 2rss feed

Best Answer

No best answer has yet been selected by Nils. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
As "Dashboard.xlsx" is already open, you should be able to just use:
Windows("Dashboard").Activate - without the .xlsx extension.
Question Author
Thanks Aquariel I'll give that a try on Monday at work.

1 to 2 of 2rss feed

Do you know the answer?

Excel Visual Basic For Apps Help Req.

Answer Question >>

Related Questions

Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.