ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Put worksheet names into worksheet Excel 2000? (https://www.excelbanter.com/excel-programming/366521-put-worksheet-names-into-worksheet-excel-2000-a.html)

James Cooper

Put worksheet names into worksheet Excel 2000?
 
Hello,

The following code gives me this error "Run-time error '9': Subscript out of
range.

What I would like to do is put 25 of the 30 worksheet names from one
workbook into the same workbook on a worksheet but this is my problem I do
not want worksheet 1-5 included.

How can the following code be modified to put 25 of the 30 worksheet names
on one worksheet in the same workbook.

Thank you for you help,
James Cooper



[email protected]

Put worksheet names into worksheet Excel 2000?
 
Hello,

I apologize I got in a hurry and did not include the code
here it is:

Sub sheets_list()
'prints sheet names to worksheet
r = ActiveCell.Row
s = ActiveCell.Column
ws = Sheets.Count
If ws 5 Then
For a = ws To 5 Step -1
Cells(r + a, s).Value = Sheets(a + 1).Name
Next a
End If
End Sub

Thank you for your help,
James Cooper



James Cooper wrote:
Hello,

The following code gives me this error "Run-time error '9': Subscript out of
range.

What I would like to do is put 25 of the 30 worksheet names from one
workbook into the same workbook on a worksheet but this is my problem I do
not want worksheet 1-5 included.

How can the following code be modified to put 25 of the 30 worksheet names
on one worksheet in the same workbook.

Thank you for you help,
James Cooper



Norman Jones

Put worksheet names into worksheet Excel 2000?
 
Hi James,

You have not included your problematic code.

However, try something like:

'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim i As Long
Dim j As Long

Set WB = Workbooks("MyTestFile.xls") '<<==== CHANGE
Set SH = WB.Sheets(1) '<<==== CHANGE

SH.Range("A1").CurrentRegion.Columns(1).ClearConte nts

For i = 6 To WB.Worksheets.Count
j = j + 1
SH.Cells(j, "A").Value = Sheets(i).name
Next i

End Sub
'<<=============


---
Regards,
Norman

"James Cooper" wrote in message
...
Hello,

The following code gives me this error "Run-time error '9': Subscript out
of range.

What I would like to do is put 25 of the 30 worksheet names from one
workbook into the same workbook on a worksheet but this is my problem I do
not want worksheet 1-5 included.

How can the following code be modified to put 25 of the 30 worksheet names
on one worksheet in the same workbook.

Thank you for you help,
James Cooper




Norman Jones

Put worksheet names into worksheet Excel 2000?
 
Hi James,

See response to your original post.


---
Regards,
Norman




All times are GMT +1. The time now is 02:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com