Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help required on macro for excel

Hello,
I have an excel file consisting of around 60 sheets. Each sheet i
named after the code of a customer/dealer. Now, I want to save eac
sheet as a new excel file with the name of the file as the name of th
sheet itself. (ie. I want to have 60 new excel files with eac
customer/dealer details sheet as one file). If one sheet is name
A0005, then this sheet should be saved as A0005.xls.

I would be very grateful if anyone of you can write a macro here whic
will allow me to be able to save such sheets as a new excel file.

Thank you very muc

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Help required on macro for excel

Hi

You could try something like


UNTESTED CODE

Sub Macro1()

Dim ws As Worksheet


For Each ws In Worksheets
ws.Activate
wsname = ws.Name

Sheets(ws.Name).Select
Sheets(ws.Name).Copy
ActiveWorkbook.SaveAs FileName:= _
"C:\Documents and Settings\Ken Macksey\My Documents\" & ws.Name &
".xls", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
False, CreateBackup:=False

Next


End Sub


HTH

Ken


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Help required on macro for excel

Hi

After a chance to test it, I added a few lines to make it run a little
better.



Sub Macro1()

Dim ws As Worksheet


Application.DisplayAlerts = False
Application.ScreenUpdating = False

For Each ws In Worksheets
ws.Activate
wsname = ws.Name

Sheets(ws.Name).Select
Sheets(ws.Name).Copy
ActiveWorkbook.SaveAs FileName:= _
"C:\Documents and Settings\Ken Macksey\My Documents\" & ws.Name &
".xls", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
False, CreateBackup:=False

ActiveWorkbook.Close

Next


Application.ScreenUpdating = True
Application.DisplayAlerts = True

End sub


Ken


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Help required on macro for excel

Hi Ken,
Yes, you improved the previous solution for speed,
you might also look at....

For a more robust solution see
Save each worksheet separately to multiple workbooks
Saveas, Save each worksheet as a separate workbook
http://www.mvps.org/dmcritchie/excel...tipleXLSfromWB

Takes care of worksheet name having same name as workbook,
and eliminates sheet1 to make it look more realistic.

Of course any links such hyperlinks or formulas will likely fail.

Provides a means of checking how big some worksheets really are,
as an additional benefit.

I don't imagine many other will find this in the archives looking for their
own solutions because the subject line has very little to do with the question.

Excel (yes, ho hum, so what, that's what these newsgroups are),
Help (ho hum), macro (yes, you're in the right group that's what this
group is all about).

The subject does not describe what you need. The only thing your
subject told is that you need a macro and know how to install and use one,
but then you poste in programming so that is expected.

Anyway I didn't find something myself in the archives -- way too many unrelated hits.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Ken Macksey" wrote in message ...
Hi

After a chance to test it, I added a few lines to make it run a little
better.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Help required on macro for excel

Sorry, Ken I was thinking your were the original poster,
places like ExcelForum with faceless id's and MS CDO
with anonymous@ makes it difficult to tell who is who anymore.
Or as the other's would say, I'm just getting older (but not wiser).

David McRitchie




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help required on macro for excel

thank you very much guys. I will definitely try these out

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Help Required Dan Wood Excel Discussion (Misc queries) 3 January 5th 10 05:49 PM
Excel macro required pcor New Users to Excel 2 January 24th 06 04:20 PM
Macro required PCOR Excel Worksheet Functions 3 December 11th 05 07:36 PM
Urgent Help Required on Excel Macro Problem Sachin Shah Excel Discussion (Misc queries) 1 August 17th 05 06:26 AM
Excel Macro Program assistance required David Moen Excel Programming 3 November 5th 03 06:07 AM


All times are GMT +1. The time now is 08:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"