• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy Data ( Specifics Range ) From Closed Workbook/Excel File

ewahyudi

New Member
Hii..


I'm VBA beginner. Would you like to share macro how to copy range data from closed workbook. Let's say, i create worbooks, the name as "VIEWER KPI.XLM", and this file can copy range data from closed workbook that record weekly achievement ex : KPI Achievement_Week 1 , KPI Achievement_Week 2 etc.

Thank you for your sharing.
 
The fastest way to learn how is to probably record a macro, do what you want it to do, and then modify it so that it will copy to the right place in future cases. If you need some suggestions beyond that, continue on:


You can tell excel to open the other spreadsheets, copy the data, and then close them...

To open:

Code:
If IsWorkbookOpen("KPI Achievement_Week1.xlsx") = False Then

[code]'To make sure the file isn't already open

[code]Workbooks.Open FileName:= "C:PathKPI Achievement_week 1.xlsx"

[code]End If


To switch between workbooks:

[code]Windows("VIEWER KPI.XLM").Activate

or

Windows("KPI Achievement_Week 1.xlsx").Activate[/code]

etc.


I'm assuming you know enough VBA to copy and paste the data... Use the macro recorder if you don't know how.


To close the file without getting a pop-up:

Windows("KPI Achievement_Week 1.xlsx").Close False[/code]


Finally, if you don't want the screen to go crazy while your user is working, put this line before you open the other file:

Application.ScreenUpdating = False[/code]


BUT... you must put this one after you close that file, or you will have problems:

Application.ScreenUpdating = True[/code]
 
Back
Top