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