![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 246
|
could someone please offer up a quick macro that returns sheet names (i.e., tab names) into a pre-defined column (let's say column B, rows 100 to 120 or so). 1 wrinkle, please return them in worksheet order (left to right). thanks.
mach3 |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: England, UK.
Posts: 526
|
Try this
Sub tabnames() numberOfSheets = Worksheets.Count For i = 1 To numberOfSheets Step 1 Cells(99+ i, 1)= Worksheets(i).Name Next i End Sub Hope this helps, RET79 |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: England, UK.
Posts: 526
|
OR even more slick, use offset:
Sub tabnames() numberOfSheets = Worksheets.Count For i = 1 To numberOfSheets Step 1 Cells(100, 1).Offset(i - 1, 0) = Worksheets(i).Name Next i End Sub |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Please also try this code.
Dim sh As Worksheet, i As Integer With Range("B100") Range(.Resize, .End(xlDown)).ClearContents 'Clear former data For Each sh In Worksheets 'Loop .Offset(i).Value = sh.Name i = i + 1 Next End With End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|