Body & Soul13 mins ago
Excel Visual Basic For Apps Help Req.
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.
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.
Answers
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.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.