AhmedThe run-time error resulted when the macro attempted to create a new tab having the same name as an existing tab when it was invoked a second time.
I've attached a modified version of the macro that addresses this problem. When activated the macro will first prompt you for a unique prefix for the tab name. Then you will be prompted for the number of sheets you want with that prefix. The two are concatenated to form a unique tab name For example First activation: Prefix = "JAN" Number of sheets = 31 Second invocation: Prefix = FEB Number of sheets =28 Your workbook will now contain 59 sheets 31 named JAN 1 - JAN 31 and 28 named FEB 1 - FEB 28. There may be a maximum number of tabs that Excel allows that may be a problem if you try to add too many tabs. Regards Tom On Thu, Nov 13, 2008 at 12:17 AM, Ahmedhonest <[EMAIL PROTECTED]> wrote: > Hello Tom, > > The coding for the macro which you have written is good and I would like to > draw your attention is that The first when the Macro is runned then there is > no problem at all and it inserts the given input for inserting the sheets. > If the macro is runned for the second time for inserting more sheets then > it is giving a Run Time Error 104. On this error i would request you to do > it yourself once and try to provide the solution. > > Thanks in advance > Regards > Ahmed > > On Thu, Nov 13, 2008 at 3:50 AM, Tom Jeffries <[EMAIL PROTECTED]> wrote: > >> The attached worksheet contains a macro (AddSheets) that will create a >> specified number of worksheets ass you describe. If you have any questions >> let me know. >> Tom >> >> On Tue, Nov 11, 2008 at 7:56 AM, Ajay Varshney < >> [EMAIL PROTECTED]> wrote: >> >>> Hi, >>> >>> Is there any macro using which i could get number of sheets in a workbook >>> equal to number of days in a month. >>> >>> For example : If i am preparing a report for October then I should get 31 >>> sheets in the workbook and if i am preparing report for November then i >>> should get 30 sheets in the workbook. >>> >>> Thanks >>> >>> >>> >> >> >> > > > -- > Ahmed Bawazir > > > > > > --~--~---------~--~----~------------~-------~--~----~ Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To post to this group, send email to excel-macros@googlegroups.com For more options, visit this group at http://groups.google.com/group/excel-macros?hl=en Visit & Join Our Orkut Community at http://www.orkut.com/Community.aspx?cmm=22913620 Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To Learn VBA Macros Please visit http://www.vbamacros.blogspot.com To see the Daily Excel Tips, Go to: http://exceldailytip.blogspot.com -~----------~----~----~----~------~----~------~--~---
AddSheets.xls
Description: MS-Excel spreadsheet