![]() |
Sheet Listing
Hi There, Looking for VBA that will put into a new sheet a listing of all sheets in the current book... Thanks D *** Sent via Developersdex http://www.developersdex.com *** |
Sheet Listing
Sub ListSheets()
Dim i As Long On Error Resume Next Worksheets.Add.Name = "Sheet List" On Error GoTo 0 Worksheets("Sheet List").Cells.ClearContents For i = 1 To ActiveWorkbook.Worksheets.Count Cells(i, "A").Value = Worksheets(i).Name Next i Columns(1).AutoFit End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Darin Kramer" wrote in message ... Hi There, Looking for VBA that will put into a new sheet a listing of all sheets in the current book... Thanks D *** Sent via Developersdex http://www.developersdex.com *** |
Sheet Listing
Option Explicit
Sub GetSheets() Dim ws As Worksheet Dim wsResult As Worksheet Set wsResult = Worksheets.Add wsResult.Name = "Result" wsResult.Range("A1") = "Sheets" For Each ws In ThisWorkbook.Worksheets If ws.Name < "Result" Then wsResult.Range("A65000").End(xlUp).Offset(1) = ws.Name End If Next End Sub "Darin Kramer" wrote: Hi There, Looking for VBA that will put into a new sheet a listing of all sheets in the current book... Thanks D *** Sent via Developersdex http://www.developersdex.com *** |
Sheet Listing
Hi Darin,
Try this. Change "ThisWorkbook" to "ActiveWorkbook" if the code is not going to be placed in the workbook you want the results in. Sub ListWorksheetNames() Dim wksTarget As Worksheet 'Change worksheet name to desired target sheet Set wksTarget = ThisWorkbook.Worksheets("Sheet1") For x = 1 To ThisWorkbook.Worksheets.Count 'Change Cells reference (Row, Column) to desired target cells wksTarget.Cells(x, 1).Value = ThisWorkbook.Worksheets(x).Name Next x End Sub Best regards John "Darin Kramer" wrote in message ... Hi There, Looking for VBA that will put into a new sheet a listing of all sheets in the current book... Thanks D *** Sent via Developersdex http://www.developersdex.com *** |
Sheet Listing
This works great - however, I have a similar problem, but I have a worksheet with multiple graphs in it. Can the code be amended so that it will also list the graph names, Thanks very much Hywel -- Hywel ------------------------------------------------------------------------ Hywel's Profile: http://www.excelforum.com/member.php...o&userid=14824 View this thread: http://www.excelforum.com/showthread...hreadid=476738 |
All times are GMT +1. The time now is 04:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com