Conveying Selected Data With An Existing Stand out File With VBA

An Stand out spreadsheet frequently contains plenty of data spread across different sheets within the same file. Sometimes you’ll have to save the data in a single sheet after which utilize it in another Stand out file. A few included in this are:

Email the information in a single sheet having a friend without delivering the entire file

When using the information in a single sheet to update another Stand out file

Saving the information into another file that’s preformatted willing and able for printing

We’ll undergo an easy example in which the objective is always to copy data in a single sheet and reserve it in a new file.

Saving Data In One Sheet And Copying It Into Another File

In order to save data into another Stand out spreadsheet, you’ll have to be aware of positioning from the second file. The activework.path command returns the road within the active file and you will then define the 2nd file location in compliance while using primary file. One advantage could it be will not matter when the code is run on another machine, the code will uncover the area.

First, we’ll define the region and name within the new file then select and duplicate the information you have to export.

Dim newFileLoc

newFileLoc = ActiveWorkbook.Path & “copy.xls”




Now we’ll open a totally new Stand out file and paste the information into sheet(1) the default then close the brand-new file.



Application.CutCopyMode = False

ActiveWorkbook.SaveAs Filename:=newFileLoc


Vid simple routine which copies the chosen cells towards the new file and saves it but there’s a couple of issues to discover.

Should you make an effort to overwrite a gift file sticking with the same name, an analog alert appears and asks if you wish to alter the file. In case you click on the no button, a mistake occurs. One of the ways with this particular is to use the approval.displayalerts=false to ignore the alert, overwriting the file.

You might make use of the file system resist determine if the file already exists, however that strategy is past the scope have to know ,. This process comes lower to knowing what you long for to attain, and comprehending the present file must be overwritten plus there is no problem.


This short snippet of code adds somewhat sophistication having a simple business process – removing information and saving it. In case you consider the quantity of clicks take part in performing this by hands, it could pay to consider using VBA making it all more effective.

Leave a Comment