Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
List of worksheets wally New Users to Excel 9 August 31st 08 07:01 PM
List specific worksheets Adrian Bear Excel Discussion (Misc queries) 5 June 2nd 08 09:54 AM
Get a list of worksheets from a WB John Scott Excel Discussion (Misc queries) 1 February 26th 06 05:47 PM
how do i list the name off all my worksheets on a sheet tthe Excel Worksheet Functions 6 November 17th 05 08:03 AM
Create list of worksheets caoimhincryan Excel Discussion (Misc queries) 0 July 28th 05 09:56 AM


All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"