Macro to work list in filter and save

R

Rich

Workbook A contains data relating to 300 towns. Column A contains the town
names.

I need to split workbook A into several workbooks, each containing one towns
data, and named the towns name.

Currently I manually Filter by the town name, run a macro to copy the data
to a new workbook and format it, the manually save by the town name.

I want to include in my macro the running down each town name in the filter,
then running the rest as per the existing macro, but finishing with saving
the new workbook as town name, which is in cell A2.

I cant figure out how to step to the next item in the filter, or how to save
as a filename based on cell contents.

Any help appreciated.

--
Rich

http://www.richdavies.com

http://www.richdavies.com/profit-protection-recruitment.htm
 
D

Dave Peterson

If wks represents the worksheet that gets the new data (with the name in A2):

with wks
'stop any warning message if the file already exists
application.displayalerts = false
.parent.saveas filename:="C:\temp\" & .range("a2").value & ".xls", _
fileformat:=xlworkbooknormal
application.displayalerts = true
end with

I put the file in C:\temp\ and overwrote any existing file with that name. And
I didn't do any checking to see if that filename was valid. And no checking to
see if the folder exists, either.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top