Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Worksheet name list from range....

I need a code that will place the list of worksheet names in a
workbook.
However I have two exceptions....

(1) I need the names to be listed starting at a specific cell. (a46)
(2) I need to dictate the range of sheet names reported.
(start name list based on 5th sheet in workbook ending at "sheet y")


Thanx.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Worksheet name list from range....

Dim iStart as long
Dim iEnd As long
Dim i As Long
Dim StartCell as Range

iStart = 5 '<===== change to suit
iEnd = 9 '<===== change to suit
Set StarCell = Range("A46") '<===== change to suit

For i = iStart to iEnd
StarCell.Offset(i-1,0).Value = Worksheets(i).Name
Next i


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"J.W. Aldridge" wrote in message
ps.com...
I need a code that will place the list of worksheet names in a
workbook.
However I have two exceptions....

(1) I need the names to be listed starting at a specific cell. (a46)
(2) I need to dictate the range of sheet names reported.
(start name list based on 5th sheet in workbook ending at "sheet y")


Thanx.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Worksheet name list from range....

Dim i as Long, j as Long, sh as Worksheet
Dim first as Long, last as Long

first = 5
last = 10
i = 0
j = 45
for each sh in Workbook.Worksheets
i = i + 1
if i = first and i <= last then
j = j + 1
Cells(j,"A").Value = sh.name
end if
Next

--
Regards,
Tom Ogilvy


"J.W. Aldridge" wrote:

I need a code that will place the list of worksheet names in a
workbook.
However I have two exceptions....

(1) I need the names to be listed starting at a specific cell. (a46)
(2) I need to dictate the range of sheet names reported.
(start name list based on 5th sheet in workbook ending at "sheet y")


Thanx.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Worksheet name list from range....

thanx.
Both codes work well however, I only have one problem....

The first sheet will always be entitled "Start" and will be the 5th
sheet.
However, the last sheet number may vary. So, I need it to stop at sheet
"end".

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Worksheet name list from range....

Dim iStart as long
Dim iEnd As long
Dim i As Long
Dim StartCell as Range

iStart = Worksheets("start").Index
iEnd = Worksheets("end").Index
Set StarCell = Range("A46") '<===== change to suit

For i = iStart to iEnd
StarCell.Offset(i-1,0).Value = Worksheets(i).Name
Next i


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"J.W. Aldridge" wrote in message
ups.com...
thanx.
Both codes work well however, I only have one problem....

The first sheet will always be entitled "Start" and will be the 5th
sheet.
However, the last sheet number may vary. So, I need it to stop at sheet
"end".





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Worksheet name list from range....

Note that worksheets("Start").Index returns an index from the sheets
collection (not the worksheets collection). Not a problem if you only have
worksheets. But to be robust you might use Sheets throughout Bob's code
rather than Worksheets.

just to illustrate with the tab order showing

Sheet1
Chart1
Sheet2
Sheet3

from the immediate window:

? worksheets("sheet2").Index
3
? worksheets(3).Name
Sheet3

--
Regards,
Tom Ogilvy



"Bob Phillips" wrote:

Dim iStart as long
Dim iEnd As long
Dim i As Long
Dim StartCell as Range

iStart = Worksheets("start").Index
iEnd = Worksheets("end").Index
Set StarCell = Range("A46") '<===== change to suit

For i = iStart to iEnd
StarCell.Offset(i-1,0).Value = Worksheets(i).Name
Next i


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"J.W. Aldridge" wrote in message
ups.com...
thanx.
Both codes work well however, I only have one problem....

The first sheet will always be entitled "Start" and will be the 5th
sheet.
However, the last sheet number may vary. So, I need it to stop at sheet
"end".




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Worksheet name list from range....

Dim j as Long, sh as Worksheet
Dim first as string, last as string
Dim bStart as Boolean

first = "start"
last = "end"
j = 45
bStart = False
for each sh in Workbook.Worksheets
if lcase(sh.name) = first then bStart = True
if bStart then
j = j + 1
Cells(j,"A").Value = sh.name
end if
if lcase(sh.Name) = "end" then exit for
Next

--
Regards,
Tom Ogilvy

"J.W. Aldridge" wrote:

thanx.
Both codes work well however, I only have one problem....

The first sheet will always be entitled "Start" and will be the 5th
sheet.
However, the last sheet number may vary. So, I need it to stop at sheet
"end".


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Worksheet name list from range....

Thanx All,


Code worked puifectly!

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
How do I paste range name list in worksheet? abaja Excel Discussion (Misc queries) 2 April 2nd 23 07:34 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Populate a list box from a worksheet range Peter Rooney Excel Programming 2 March 9th 06 11:14 AM
Using a data validation list to look up a defined named range in another worksheet Laura Hunt Charts and Charting in Excel 0 November 24th 05 02:29 PM
Condensing a list/range with blank cells to a new list/range without blanks KR Excel Worksheet Functions 4 July 5th 05 04:23 PM


All times are GMT +1. The time now is 06:27 PM.

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

About Us

"It's about Microsoft Excel"