excel macro split data

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

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

Excel macro to split data into separate files | Access forum

resolvedResolved · Low Priority · Version 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:

Create An Inaccessible Field On A Form

There is sometimes a need to make a field in a form look like a normal field but be completely inaccessible to the user. To do this:

In the Field's Properties
Set the ENABLED property to No
Set the LOCKED property to Yes

The field will not grey out, but the user will not be able to do anything with it.

View all Access hints and tips


Server loaded in 0.08 secs.