Macro for listing sheet names

I have this macro (inherited from another user) that will take all the sheet 
names and put it in a list.  My problem is it lists the last sheet first.  I 
need it skip the first sheet which is my master list and then starting with 
the next sheet put them in order. Sheet1, Sheet2 etc.  I know there is 
something that is telling it what order to compile it, I just don't what.  

Thanks,

cao

Sub WorksheetNamesList()
    Dim wCtr As Long
    Dim rCtr As Long
    rCtr = 1
    For wCtr = Worksheets.Count To 2 Step -1
        rCtr = rCtr + 1
        With ActiveSheet.Cells(rCtr, 1)
            .NumberFormat = "@" 'text
            .Value = Sheets(wCtr).Name
        End With
    Next wCtr
    
End Sub
0
srctr (12)
7/29/2009 6:58:01 PM
excel 39879 articles. 2 followers. Follow

3 Replies
462 Views

Similar Articles

[PageSpeed] 43

Sub WorksheetNamesList()
    Dim wCtr As Long
    Dim rCtr As Long
    rCtr = 1
    For wCtr = 2 To Worksheets.Count
        rCtr = rCtr + 1
        With ActiveSheet.Cells(rCtr, 1)
            .NumberFormat = "@" 'text
            .Value = Sheets(wCtr).Name
        End With
    Next wCtr
End Sub
-- 
Jim Cone
Portland, Oregon  USA




"srctr" <srctr@discussions.microsoft.com> 
wrote in message 
I have this macro (inherited from another user) that will take all the sheet 
names and put it in a list.  My problem is it lists the last sheet first.  I 
need it skip the first sheet which is my master list and then starting with 
the next sheet put them in order. Sheet1, Sheet2 etc.  I know there is 
something that is telling it what order to compile it, I just don't what.  
Thanks,
cao

Sub WorksheetNamesList()
    Dim wCtr As Long
    Dim rCtr As Long
    rCtr = 1
    For wCtr = Worksheets.Count To 2 Step -1
        rCtr = rCtr + 1
        With ActiveSheet.Cells(rCtr, 1)
            .NumberFormat = "@" 'text
            .Value = Sheets(wCtr).Name
        End With
    Next wCtr    
End Sub
0
7/29/2009 7:45:10 PM
To list all sheets in order, omitting the first:
Change
For wCtr = Worksheets.Count To 2 Step -1
to
For wCtr = 2 To Worksheets.Count


Here is an alternative

Sub WorksheetNamesList()
    Dim wCtr
    Dim rCtr As Long
    rCtr = 1
    For Each wCtr In Worksheets
        If wCtr.Name <> "Master" Then
          rCtr = rCtr + 1
          With ActiveSheet.Cells(rCtr, 1)
            .NumberFormat = "@" 'text
            .Value = wCtr.Name
          End With
        End If
    Next wCtr

End Sub

-- 
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"srctr" <srctr@discussions.microsoft.com> wrote in message 
news:EC09DB96-36D4-4AD4-85EA-703B753724C3@microsoft.com...
> I have this macro (inherited from another user) that will take all the 
> sheet
> names and put it in a list.  My problem is it lists the last sheet first. 
> I
> need it skip the first sheet which is my master list and then starting 
> with
> the next sheet put them in order. Sheet1, Sheet2 etc.  I know there is
> something that is telling it what order to compile it, I just don't what.
>
> Thanks,
>
> cao
>
> Sub WorksheetNamesList()
>    Dim wCtr As Long
>    Dim rCtr As Long
>    rCtr = 1
>    For wCtr = Worksheets.Count To 2 Step -1
>        rCtr = rCtr + 1
>        With ActiveSheet.Cells(rCtr, 1)
>            .NumberFormat = "@" 'text
>            .Value = Sheets(wCtr).Name
>        End With
>    Next wCtr
>
> End Sub 


0
bliengme (657)
7/29/2009 7:55:52 PM
Sub simplesheetlist()
For i = 2 To Worksheets.Count
   Cells(i, 1) = Sheets(i).Name
Next i
End Sub

-- 
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com
"srctr" <srctr@discussions.microsoft.com> wrote in message 
news:EC09DB96-36D4-4AD4-85EA-703B753724C3@microsoft.com...
>I have this macro (inherited from another user) that will take all the 
>sheet
> names and put it in a list.  My problem is it lists the last sheet first. 
> I
> need it skip the first sheet which is my master list and then starting 
> with
> the next sheet put them in order. Sheet1, Sheet2 etc.  I know there is
> something that is telling it what order to compile it, I just don't what.
>
> Thanks,
>
> cao
>
> Sub WorksheetNamesList()
>    Dim wCtr As Long
>    Dim rCtr As Long
>    rCtr = 1
>    For wCtr = Worksheets.Count To 2 Step -1
>        rCtr = rCtr + 1
>        With ActiveSheet.Cells(rCtr, 1)
>            .NumberFormat = "@" 'text
>            .Value = Sheets(wCtr).Name
>        End With
>    Next wCtr
>
> End Sub 

0
dguillett1 (2487)
7/29/2009 8:23:33 PM
Reply:

Similar Artilces:

Macro warning with no macros
I have a workbook that when I try to open it I get the warning tellin me it contains macros and asking whether I want to Enable or Disabl them. I put no macros, no VB scripts, nothing at all in the workboo other than standard Excel formulas and some charts. I developed it i Excel 2002, SP-2, but have moved it back and forth between tw computers, the other which has Excel 97. Regardless of whether Enable or Disable or change the security settings so as not to get th warning, once the workbook is open even if I go t Tools-Macro-Macros... it lists no macros. How can I find out what's cau...

Another address list ?
Hi - I am running Exchange 2003 on Win2003 SBS edition. Could someone tell me whether it is possible to have another address list which exists separate to the GAL ? So for example if you compose a new message and click on the To button, I would like the users to see the GAL and also another entry underneath saying "External Emails" which will have the external user email addresses in it" How do you go about doing this ? Thanks in advance You would create this in the Address Lists container in Exchange System Manager. "Edward" <dont-mail@me.com> wrote...

List Control
I want to add list control header like "First Column", "Second Column", I would like it is showed as 2 lines header by "First \nColumn", "Second \nColumn", But it does not work. How to do that? ...

Get the name of the version
Hi, When I used the Application.version it gave me a number like 10.0, how I can get the corresponding name of the the version like Excel 97, Excel 2002... ? Thank you. There is no property that returns the full name of the product, as far as I know. You could make your own little lookup/conversion routine as there are not that many versions. -- Jim Rech Excel MVP "Ben" <barben02@yahoo.com> wrote in message news:263001c41ca8$1d03faa0$3501280a@phx.gbl... | Hi, | | When I used the Application.version it gave me a number | like 10.0, how I can get the corresponding name...

Macro
Can anybody tell me how to kick off a macro automatically as file is opened? Regards ...

Macro
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: intel Hi, I'm thinking of buying Mac: Office 2008, but before I do I want to check that I will be able to download Scritpsmart collection of templates without any glitches: <http://www.bbc.co.uk/writersroom/scriptsmart/faq.shtml> Does anyone know if I can do this? Regards, SP. In article <ee98ff5.-1@webcrossing.caR9absDaxw>, StregaItalia@officeformac.com wrote: > Version: 2008 > Operating System: Mac OS X 10.4 (Tiger) > Processor: intel > > Hi, > > I'm thinking of buying Mac: Of...

Database is not listed in ODBC to default
Hi! I am trying to create a ODBC and default the Database in order for this ODBC to use in Crysral Reports, but I could see all Databases except the one I am looking for. I am using Windows Authentication and Namedpipes in the settings and necessary access has been given in SQL for this Windows user. I've tried even creating a new ODBC, it doesn't show the database that I'm looking for. Does any one experienced this before? Regards, Venkata N M Punugu If you are using Windows authentication, make sure the Windows user is added to the database. -- Charles Allen, MVP ...

Run macro automatically.
How do I make a macro run automatically when a worksheet it is attached to is loaded? right click on the sheet tab>view code>left window worksheet>right window activate -- Don Guillett SalesAid Software donaldb@281.com "Excel macro" <Excel macro@discussions.microsoft.com> wrote in message news:DD7AF1E3-9263-4523-AC49-A43ABA1AB9D0@microsoft.com... > How do I make a macro run automatically when a worksheet it is attached to is > loaded? I am unable to find "activate " when I right click on worksheet. ( i assume that you are referring to the windo...

Help with macro/and or formula?
Perhaps this is a silly question, but i just can't figure out how t format this worksheet. The problem is that a lot of the cells hav numbers in them with negative signs in the back instead of in the fron (ie. 23-) and i was wondering if anyone knew of a macro/formula i coul use to quickly fix this problem for all the cells. I would b extremely grateful. Thanks -- brefed1 ----------------------------------------------------------------------- brefed15's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3557 View this thread: http://www.excelforum.com/showthre...

Attached Toolbars Macros
Excel 2003 I have a custom tool bar, this tool bar has several items, each item is pointing to a VBA code. This tool bar is attached to the worksheet. I've copied this spreadsheet to several computers. After I copied the spreadsheet I decided to rename the spreadsheet, after I renamed the spreadsheet the Toolbar Item's macros were still pointing to the old name, I reasigned each tool bar item to the current spreadsheet, saved the spreadsheet and everything was working on my computer, but when I re-copied the new spreadsheet to other computers and I clicked on the Toolbar Item...

How to make worksheet name as variable?
In my workbook, some formulas are like this: =SUMPRODUCT(($E2<'sheet01'!$G$1:$G$500)*($F2>'sheet01'!$G$1:$G$500)*($C2='sheet01'!$E$1:$E$500)*($B2='sheet01'!$F$1:$F$500),'sheet01'!$J$1:$J$500) 'sheet01' is the name of one of my worksheets. It appears several time in the worksheet. When I want to make them refer to another worksheet, I have to change many instances of the name. Can I input the worksheet name into one of the cells, and the formulas get the name from the cell, so that I just have to change it once? Thanks in advance!! ...

Protected sheets and running macros
i have a sheet with a macro ran by a normal button at the top. Howeve when i protect the worksheet where ever i click on the sheet the macr executes. Can any one offer any advice on how to stop this? Thanks Robert -- Message posted from http://www.ExcelForum.com hi, i am not able to reproduce the problem, hence i may not be able t provide a panacea for that issue. here is what i suggest. i have a sheet that has a macro that is run when a control toolbo button (that is, not a form button) is clicked. this sheet is protected based on the user logged in. what i have don is to protect t...

RE: last post about listing e-mail address rather than name.......
That is in Outlook Express 6.0. BTW, is there a separate newsgroup for Outlook Express...I couldn't find one?!!!!! ...

Macro to remove rows?
Hi, I receive thousands of rows of data from an extract that comes from a database. The data extract automatically generates page headers that need to be removed, and I would love to automate this process. The headers do have a pattern to them, but I'm not clever enough to figure out a good way to use that to write a macro. The first row of the header starts with hyphens ------------------------------- Then there's a variable number of rows of header data to delete followed by another row of hyphens ------------------------------- Then 2 additional rows that must be deleted. The nu...

Macro Freezes Reading Pane
I have a macro that Sends/Receives Tasks from Project Server into Outlook Tasks. Everything is working fine, except one weird thing that happens. I have the Timer set on the macro and it starts as soon as Outlook starts. The macro gets the tasks from ProjectServer every hour. As soon as the macro starts running the Reading pane freezes in the Inbox. If i stop the macro then Reading pane is back to normal. Can anyone please tell me if there is something I can do in VBA to fix this annoying issue. Thanks a lot ...

Lists
Okay I am new to excell bar drawing little spreadsheets to do my own financing. I am currently setting up a sheet and need the users to be able to select from a list of options only and not input thier own text - does that make sense? also i ahve 12 names on the list and one master with all on - would like the data entered on to a names list to be automatically entered onto the master or vice versa which ever is easiest. sorry if this sounds jumbled but i am totally lost and this has to look really hot for work! regards Kelly - England Hi Kerry, don't know a great deal on forms ...

Calling on a macro within a macro!
Hey All!! Quick Question - How do you call up a macro within a current macro? I have one big macro and I need it to jump to several other macros when it runs! Does it matter where the other macros are stored or is it better to have them all in one module? Help appreciated Thnx! Hi Mellowe, '=============>> Public Sub Main() 'Your code Call One 'your code End Sub '<<============= '=============>> Public Sub One() MsgBox "Hi from One" End Sub '<<============= > Does it matter where the other macros are stored or ...

How to rotate List Control?
Hi, in my project i need rotated list control. does anyone know how to make this? thx What do you mean by "rotated?" > Hi, > > in my project i need rotated list control. does anyone know > how to make > this? > > thx David Crow schrieb: > What do you mean by "rotated?" > >> Hi, >> >> in my project i need rotated list control. does anyone know >> how to make >> this? >> >> thx > normal list control (horizontal text adjustment): ----------------- | | ----------------- | | -------------...

Change default "Show names from the:" option
Clicking the "To:" button in a new Outlook email message brings up the "Select Names" dialog box. This dialog displays the contents of contact databases such as My Outlook Address Book and Global Address List. Is there a way to change the default database selected in the "Show names from the:" line from the current Global Address List to the contacts in my Outlook Address Book? My version of Outlook connects with an Exchange server to acces mail, contacts, etc. Thanks for any suggestions, Kerry You probably meant to post your Outlook version so we coul...

shortcut keys to macros
Hi, Is it at all possible to assign shortcut keys to macros in Outlook? Thx, Hans ...

How to work with a list
Hi, I try to test a list of databases nothing in liste.out Can you help me ? Dim fso, infile, aNames, sBase, shell set fso = createobject("scripting.filesystemobject") set infile = fso.opentextfile("liste.txt",1) Set shell = WScript.CreateObject("WScript.Shell") aNames = Split(infile.readall, vbnewline) infile.close for each sBase in aNames wsh.echo "Base:", sBase shell.Run "tnsping sBase >> liste.out" Next "bob123" <bob123@gmail.com> wrote in message news:4c3d7e10$0$10071$426a74cc@news...

Distribution List members gets a message more then once
Hi, I created a Distribution List group that contains some members with an external EMail Address(regular smtp address) and some with an Exchange Mail box. It Appears that the users with the Exchange EMail Address gets each message more then once.They get once in an hour the same message again. Where did I go wrong? Please help. Thanks, Shif Arad HI I am also getting this problem We have just changed our Internet Connection, and therefore created a new Routing Connection. Does anyone know if this is related Thank Mat ----- Shif Arad wrote: ---- Hi I created a...

Macro that password protects a sheet
I am attempting to create a macro that can open a protected sheet, change something, and then protect it again. I continue to have an issue with the macro not entering the password. Is this possible to do/fix? Thanks, Ryan ..open password="mypassword" -- Don Guillett SalesAid Software donaldb@281.com "Ryan" <Ryan@discussions.microsoft.com> wrote in message news:D4780ED8-CA1D-4284-97BC-3576160D998E@microsoft.com... > I am attempting to create a macro that can open a protected sheet, change > something, and then protect it again. I continue to have an iss...

Excluding members of a distribution list
Is it possible to send mail to a Distribution list, but to tell it to exclude member(s) from that list for this piece of mail? Thanks... Dennis Snelgrove <dennis.snelgrove@regional.niagara.on.ca> wrote: > Is it possible to send mail to a Distribution list, but to tell it to > exclude member(s) from that list for this piece of mail? No. With Outlook 2003, though, you can click the plus sign to the left of the DL, have OL expand it, and then delete the individual address. -- Brian Tillman ...

help Unable to record Macro !!!!!!!
I want to record a macro in excel.But as soon as I click record Macro it says "unable to record" macro. Got no help in excel help.I do this same thing in word and it's working. Please help It's urgent for me !!!1 Have a look here http://groups.google.com/groups?as_epq=unable%20to%20record&as_ugroup=microsoft.public.excel.* -- Don Guillett SalesAid Software donaldb@281.com "ash" <anonymous@discussions.microsoft.com> wrote in message news:3e0b01c42ae5$45333e00$a401280a@phx.gbl... > I want to record a macro in excel.But as soon as I click > record...