Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA list all worksheets
CAn anyone help me use this code from MSDN
I'm trying to easily generate a list of worksheets in a workbook. Private Sub ListSheets() Dim sh As Excel.Worksheet Dim rng As Excel.Range Dim i As Integer rng = ThisApplication.Range("rangeSheets") For Each sh In ThisWorkbook.Sheets rng.Offset(i, 0).Value = sh.Name i = i + 1 Next sh End Sub Thanks Bra -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA list all worksheets
Code: -------------------- Private Sub ListSheets() Dim sh As Excel.Worksheet Dim rng As Excel.Range Dim i As Integer Set rng = Range("rangeSheets") For Each sh In ThisWorkbook.Sheets rng.Offset(i, 0).Value = sh.Name i = i + 1 Next sh End Sub -------------------- make sure you name a cell "rangeSheets" in your workbook. Or you could simply replace "rangeSheets" above with your desired range, ie "A1" --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA list all worksheets
Hi
and what is your exact problem?. You have to define the name 'rangesheets' first before running this macro -----Original Message----- CAn anyone help me use this code from MSDN I'm trying to easily generate a list of worksheets in a workbook. Private Sub ListSheets() Dim sh As Excel.Worksheet Dim rng As Excel.Range Dim i As Integer rng = ThisApplication.Range("rangeSheets") For Each sh In ThisWorkbook.Sheets rng.Offset(i, 0).Value = sh.Name i = i + 1 Next sh End Sub Thanks Brad --- Message posted from http://www.ExcelForum.com/ . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
List of worksheets | New Users to Excel | |||
List specific worksheets | Excel Discussion (Misc queries) | |||
Get a list of worksheets from a WB | Excel Discussion (Misc queries) | |||
how do i list the name off all my worksheets on a sheet | Excel Worksheet Functions | |||
Create list of worksheets | Excel Discussion (Misc queries) |