Amit, I do not know which file you are using it on, so I cannot be sure, but the code should work if you can MOVE the entire Sorter sheet from my attachment to your workbook, and ideally make it the very first sheet. If you are still not able to get it to work, you might have to share your actual workbook.
Regards, Sam On Mon, Nov 14, 2011 at 6:17 AM, Amit Desai (MERU) <amit.de...@merucabs.com>wrote: > Dear Sam, > > Its working in the excel file attached..but its not working in other file > how should I do.. > > The modified script is as below, is it correct? > > Sub GetListOfSheets() > > Dim lng As Long > Worksheets("..Sorter..").UsedRange.ClearContents > For lng = 1 To Sheets.Count > If lng <> Worksheets("..Sorter..").Index Then > Cells(lng, 1).Value = Sheets(lng).Name > End If > Next lng > > End Sub > > -----Original Message----- > From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] > On Behalf Of Sam Mathai Chacko > Sent: 14 November 2011 07:00 > To: excel-macros@googlegroups.com > Subject: Re: $$Excel-Macros$$ Listing name of worksheet & renaming them > > There is a sheet by the name ..Sorter.. > In the first column of the sheet you can get the list of all sheets in > the workbook by clicking on the first button. in the next column, you > have to type the new names of those sheets. then click on the 2nd and > 3rd buttons. > > I could have added a line in the first routine to clear all cells in > the sorter sheet just to ensure there are no names of sheets the do > not exist. you can add that line in the first sub-routine > > Worksheets("..Sorter..").UsedRange.ClearContents > > Sam > > On 14/11/2011, Amit Desai (MERU) <amit.de...@merucabs.com> wrote: > > Thanks.. but I am getting some error.. > > > > While renaming, I am getting an error "500" & some time "out of range". > > > > > > Where should I paste the data for newssheet name? > > > > From: excel-macros@googlegroups.com [mailto: > excel-macros@googlegroups.com] > > On Behalf Of Sam Mathai Chacko > > Sent: 13 November 2011 23:02 > > To: excel-macros@googlegroups.com > > Subject: Re: $$Excel-Macros$$ Listing name of worksheet & renaming them > > > > Would it be OK if you had to click 3 buttons for that? > > > > Macro used > > > > Option Explicit > > > > Sub GetListOfSheets() > > > > Dim lng As Long > > For lng = 1 To Sheets.Count > > If lng <> Worksheets("..Sorter..").Index Then > > Cells(lng, 1).Value = Sheets(lng).Name > > End If > > Next lng > > > > End Sub > > > > Sub RenameSheetTo() > > > > Dim lng As Long > > For lng = 1 To ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row > > If Trim(Cells(lng, 1).Value) <> "" And lng <> > > Worksheets("..Sorter..").Index Then > > ThisWorkbook.Sheets(CStr(Cells(lng, 1).Value)).Name = > > Left(Cells(lng, 2).Value, 31) > > End If > > Next lng > > > > End Sub > > > > Sub SortSheets() > > > > Dim lCount As Long, lCounted As Long, lCount2 As Long > > Dim lShtLast As Long > > Dim lReply As Long > > > > lReply = MsgBox("To sort Worksheets ascending, select 'Yes'. To sort > > Worksheets descending select 'No'", vbYesNoCancel, "Ozgrid Sheet Sort") > > If lReply = vbCancel Then Exit Sub > > lShtLast = Sheets.Count > > If lReply = vbYes Then 'Sort ascending > > For lCount = 1 To lShtLast > > For lCount2 = lCount To lShtLast > > If UCase(Sheets(lCount2).Name) < > UCase(Sheets(lCount).Name) > > Then > > Sheets(lCount2).Move Before:=Sheets(lCount) > > End If > > Next lCount2 > > Next lCount > > Else 'Sort descending > > For lCount = 1 To lShtLast > > For lCount2 = lCount To lShtLast > > If UCase(Sheets(lCount2).Name) > > UCase(Sheets(lCount).Name) > > Then > > Sheets(lCount2).Move Before:=Sheets(lCount) > > End If > > Next lCount2 > > Next lCount > > End If > > > > End Sub > > > > The Sort macro was copied from Ozgrid > > http://www.ozgrid.com/VBA/sort-sheets.htm > > > > Regards, > > Sam Mathai Chacko > > On Sun, Nov 13, 2011 at 9:34 PM, Amit Desai (MERU) > > <amit.de...@merucabs.com<mailto:amit.de...@merucabs.com>> wrote: > > Thanks...this helps changing the name of sheet all at once...but..I need > 3 > > things, > > > > > > 1) List the names of work sheet in one black sheet of the file, > > > > 2) Change the name of worksheet all at once (have a macro), > > > > 3) Arrange the worksheet either alphabetically or as needed (have a > > macro)... > > > > Can you all please provide one in all macro for all above task? > > > > From: excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com > > > > > [mailto:excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com > >] > > On Behalf Of Sam Mathai Chacko > > Sent: 13 November 2011 18:29 > > > > To: excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com> > > Subject: Re: $$Excel-Macros$$ Listing name of worksheet & renaming them > > > > Here's how you can do it > > > > > > Sub RenameSheetTo() > > > > Dim lng As Long > > For lng = 1 To ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row > > ThisWorkbook.Worksheets(Cells(lng, 1).Value).Name = Cells(lng, > > 2).Value > > Next lng > > > > End Sub > > > > Regards, > > Sam Mathai Chacko > > On Sun, Nov 13, 2011 at 2:20 PM, Amit Desai (MERU) > > <amit.de...@merucabs.com<mailto:amit.de...@merucabs.com>> wrote: > > Thanks.. this helped me in arranging it..but how to list & rename it.. > > say..Sheet A to become C, R to become S etc... > > From: excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com > > > > > [mailto:excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com > >] > > On Behalf Of Aindril De > > > > Sent: 13 November 2011 14:04 > > To: excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com> > > Subject: Re: $$Excel-Macros$$ Listing name of worksheet & renaming them > > > > Pl chk this, > > > > http://support.microsoft.com/kb/812386 > > > > Cheers, > > Andy > > On Sun, Nov 13, 2011 at 1:36 PM, Amit Desai (MERU) > > <amit.de...@merucabs.com<mailto:amit.de...@merucabs.com>> wrote: > > Dear Master, > > > > I have an excel file with sheet names ranging from A to V. However I want > to > > change its sequence post changing its name. > > > > Do we have any shortcut? > > > > Regards, > > Amit Desai > > AM - MIS Corporate > > Meru Cabs Company Pvt.Ltd > > Mumbai > > Mob:9867232534 > > > > [cid:image001.gif@01CCA263.4F5515E0] > > > > > > ________________________________ > > Disclaimer: This message and its attachments contain confidential > > information and may also contain legally privileged information. This > > message is intended solely for the named addressee. If you are not the > > addressee indicated in this message (or authorized to receive for > > addressee), you may not copy or deliver any part of this message or its > > attachments to anyone or use any part of this message or its attachments. > > Rather, you should permanently delete this message and its attachments > (and > > all copies) from your system and kindly notify the sender by reply > e-mail. > > Any content of this message and its attachments that does not relate to > the > > official business of Meru Cab Company Pvt. Ltd. must be taken not to have > > been sent or endorsed by any of them. Email communications are not > private > > and no warranty is made that e-mail communications are timely, secure or > > free from computer virus or other defect. > > -- > > FORUM RULES (934+ members already BANNED for violation) > > > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will > > not get quick attention or may not be answered. > > > > 2) Don't post a question in the thread of another member. > > > > 3) Don't post questions regarding breaking or bypassing any security > > measure. > > > > 4) Acknowledge the responses you receive, good or bad. > > > > 5) Cross-promotion of, or links to, forums competitive to this forum in > > signatures are prohibited. > > > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > > owners and members are not responsible for any loss. > > > > > > ---------------------------------------------------------------------------- > -------------------------- > > To post to this group, send email to > > excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com> > > > > > > > > -- > > > > > > -- > > FORUM RULES (934+ members already BANNED for violation) > > > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will > > not get quick attention or may not be answered. > > > > 2) Don't post a question in the thread of another member. > > > > 3) Don't post questions regarding breaking or bypassing any security > > measure. > > > > 4) Acknowledge the responses you receive, good or bad. > > > > 5) Cross-promotion of, or links to, forums competitive to this forum in > > signatures are prohibited. > > > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > > owners and members are not responsible for any loss. > > > > > > ---------------------------------------------------------------------------- > -------------------------- > > To post to this group, send email to > > excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com> > > > > ________________________________ > > Disclaimer: This message and its attachments contain confidential > > information and may also contain legally privileged information. This > > message is intended solely for the named addressee. If you are not the > > addressee indicated in this message (or authorized to receive for > > addressee), you may not copy or deliver any part of this message or its > > attachments to anyone or use any part of this message or its attachments. > > Rather, you should permanently delete this message and its attachments > (and > > all copies) from your system and kindly notify the sender by reply > e-mail. > > Any content of this message and its attachments that does not relate to > the > > official business of Meru Cab Company Pvt. Ltd. must be taken not to have > > been sent or endorsed by any of them. Email communications are not > private > > and no warranty is made that e-mail communications are timely, secure or > > free from computer virus or other defect. > > -- > > FORUM RULES (934+ members already BANNED for violation) > > > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will > > not get quick attention or may not be answered. > > > > 2) Don't post a question in the thread of another member. > > > > 3) Don't post questions regarding breaking or bypassing any security > > measure. > > > > 4) Acknowledge the responses you receive, good or bad. > > > > 5) Cross-promotion of, or links to, forums competitive to this forum in > > signatures are prohibited. > > > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > > owners and members are not responsible for any loss. > > > > > > ---------------------------------------------------------------------------- > -------------------------- > > To post to this group, send email to > > excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com> > > > > > > > > -- > > Sam Mathai Chacko > > -- > > FORUM RULES (934+ members already BANNED for violation) > > > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will > > not get quick attention or may not be answered. > > > > 2) Don't post a question in the thread of another member. > > > > 3) Don't post questions regarding breaking or bypassing any security > > measure. > > > > 4) Acknowledge the responses you receive, good or bad. > > > > 5) Cross-promotion of, or links to, forums competitive to this forum in > > signatures are prohibited. > > > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > > owners and members are not responsible for any loss. > > > > > > ---------------------------------------------------------------------------- > -------------------------- > > To post to this group, send email to > > excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com> > > > > ________________________________ > > Disclaimer: This message and its attachments contain confidential > > information and may also contain legally privileged information. This > > message is intended solely for the named addressee. If you are not the > > addressee indicated in this message (or authorized to receive for > > addressee), you may not copy or deliver any part of this message or its > > attachments to anyone or use any part of this message or its attachments. > > Rather, you should permanently delete this message and its attachments > (and > > all copies) from your system and kindly notify the sender by reply > e-mail. > > Any content of this message and its attachments that does not relate to > the > > official business of Meru Cab Company Pvt. Ltd. must be taken not to have > > been sent or endorsed by any of them. Email communications are not > private > > and no warranty is made that e-mail communications are timely, secure or > > free from computer virus or other defect. > > -- > > FORUM RULES (934+ members already BANNED for violation) > > > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will > > not get quick attention or may not be answered. > > > > 2) Don't post a question in the thread of another member. > > > > 3) Don't post questions regarding breaking or bypassing any security > > measure. > > > > 4) Acknowledge the responses you receive, good or bad. > > > > 5) Cross-promotion of, or links to, forums competitive to this forum in > > signatures are prohibited. > > > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > > owners and members are not responsible for any loss. > > > > > > ---------------------------------------------------------------------------- > -------------------------- > > To post to this group, send email to > > excel-macros@googlegroups.com<mailto:excel-macros@googlegroups.com> > > > > > > > > -- > > Sam Mathai Chacko > > -- > > FORUM RULES (934+ members already BANNED for violation) > > > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will > > not get quick attention or may not be answered. > > > > 2) Don't post a question in the thread of another member. > > > > 3) Don't post questions regarding breaking or bypassing any security > > measure. > > > > 4) Acknowledge the responses you receive, good or bad. > > > > 5) Cross-promotion of, or links to, forums competitive to this forum in > > signatures are prohibited. > > > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > > owners and members are not responsible for any loss. > > > > > > ---------------------------------------------------------------------------- > -------------------------- > > To post to this group, send email to excel-macros@googlegroups.com > > > > ________________________________ > > Disclaimer: This message and its attachments contain confidential > > information and may also contain legally privileged information. This > > message is intended solely for the named addressee. If you are not the > > addressee indicated in this message (or authorized to receive for > > addressee), you may not copy or deliver any part of this message or its > > attachments to anyone or use any part of this message or its attachments. > > Rather, you should permanently delete this message and its attachments > (and > > all copies) from your system and kindly notify the sender by reply > e-mail. > > Any content of this message and its attachments that does not relate to > the > > official business of Meru Cab Company Pvt. Ltd. must be taken not to have > > been sent or endorsed by any of them. Email communications are not > private > > and no warranty is made that e-mail communications are timely, secure or > > free from computer virus or other defect. > > > > -- > > FORUM RULES (934+ members already BANNED for violation) > > > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will > > not get quick attention or may not be answered. > > > > 2) Don't post a question in the thread of another member. > > > > 3) Don't post questions regarding breaking or bypassing any security > > measure. > > > > 4) Acknowledge the responses you receive, good or bad. > > > > 5) Cross-promotion of, or links to, forums competitive to this forum in > > signatures are prohibited. > > > > NOTE : Don't ever post personal or confidential data in a workbook. > Forum > > owners and members are not responsible for any loss. > > > > > > ---------------------------------------------------------------------------- > -------------------------- > > To post to this group, send email to excel-macros@googlegroups.com > > > > -- > Sent from my mobile device > > Sam Mathai Chacko > > -- > FORUM RULES (934+ members already BANNED for violation) > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will > not get quick attention or may not be answered. > > 2) Don't post a question in the thread of another member. > > 3) Don't post questions regarding breaking or bypassing any security > measure. > > 4) Acknowledge the responses you receive, good or bad. > > 5) Cross-promotion of, or links to, forums competitive to this forum in > signatures are prohibited. > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > owners and members are not responsible for any loss. > > > ---------------------------------------------------------------------------- > -------------------------- > To post to this group, send email to excel-macros@googlegroups.com > > > Disclaimer: This message and its attachments contain confidential > information and may also contain legally privileged information. This > message is intended solely for the named addressee. If you are not the > addressee indicated in this message (or authorized to receive for > addressee), you may not copy or deliver any part of this message or its > attachments to anyone or use any part of this message or its attachments. > Rather, you should permanently delete this message and its attachments (and > all copies) from your system and kindly notify the sender by reply e-mail. > Any content of this message and its attachments that does not relate to the > official business of Meru Cab Company Pvt. Ltd. must be taken not to have > been sent or endorsed by any of them. Email communications are not private > and no warranty is made that e-mail communications are timely, secure or > free from computer virus or other defect. > > -- > FORUM RULES (934+ members already BANNED for violation) > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > > 2) Don't post a question in the thread of another member. > > 3) Don't post questions regarding breaking or bypassing any security > measure. > > 4) Acknowledge the responses you receive, good or bad. > > 5) Cross-promotion of, or links to, forums competitive to this forum in > signatures are prohibited. > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > owners and members are not responsible for any loss. > > > ------------------------------------------------------------------------------------------------------ > To post to this group, send email to excel-macros@googlegroups.com > -- Sam Mathai Chacko -- FORUM RULES (934+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com