Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel macro split data

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Excel macro to split data into separate files

Excel macro to split data into separate files

ResolvedVersion 2007

Marta has attended:
Access VBA course

Excel macro to split data into separate files

How can I set up a macro that would split my Excel data into separate files based on information within the file (for example a list of agencies) and save the files separately naming them appropriately for each agency?

RE: Excel macro to split data into separate files

Hi Marta, thanks for your query. You'll need to amend the following for your purposes but this is the code to dump out the activesheet as a standalone file. You'll need to loop through your agency names and problem select particular ranges and/or copy them onto fresh sheets, but the whole thing can be done invisibly. Here's the basic code:

-------

Dim mynewfilename As String
Dim myagencyname as string

myagencyname = [Your code here]

mynewfilename = "C:\" & myagencyname & ".xls"

Activesheet.Select
Activesheet.Copy

ActiveWorkbook.SaveAs Filename:=mynewfilename

ActiveWorkbook.Close

-------

Hope this helps,

Anthony

Fri 16 Mar 2012: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Access tip:

Display current date & time in column of any width

The worksheet function =NOW() returns the current date & time. When entered into a column which is not wide enough to display the value NOW returns, the cell displays ###

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.