ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sub to aquire list of worksheets (https://www.excelbanter.com/excel-programming/317100-sub-aquire-list-worksheets.html)

aking1987[_11_]

Sub to aquire list of worksheets
 

AA2e72E Wrote:
Sub xx()
Range("A1").Select
For Each Sheet In ActiveWorkbook.Sheets
Select Case Sheet.Name
Case "EG1"
'Ignore
Else
ActiveCell.Value = Sheet.Name
Cells(Cells.Row + 1, Cells.Column).Activate
End Select
Next
End Sub


Else Without If


Code
-------------------

Sub MacroAddNewFileListSheetNames()
' Creates a list of names of the sheets in SHEET Master Numbers, Column I (emitts Master Numbers)

Range("I1").Select
For Each Sheet In ActiveWorkbook.Worksheets
Select Case Sheet.Name
Case "Master Numbers"
'Ignore
Else
ActiveCell.Value = Sheet.Name
Cells(Cells.Row + 1, Cells.Column).Activate
End Select
Next

End Su
-------------------

--
aking198
-----------------------------------------------------------------------
aking1987's Profile: http://www.excelforum.com/member.php...fo&userid=1539
View this thread: http://www.excelforum.com/showthread.php?threadid=31434


AA2e72E

Sub to aquire list of worksheets
 
Oops!

Replace the line

Else

by

Case Else

"aking1987" wrote:


AA2e72E Wrote:
Sub xx()
Range("A1").Select
For Each Sheet In ActiveWorkbook.Sheets
Select Case Sheet.Name
Case "EG1"
'Ignore
Else
ActiveCell.Value = Sheet.Name
Cells(Cells.Row + 1, Cells.Column).Activate
End Select
Next
End Sub


Else Without If


Code:
--------------------

Sub MacroAddNewFileListSheetNames()
' Creates a list of names of the sheets in SHEET Master Numbers, Column I (emitts Master Numbers)

Range("I1").Select
For Each Sheet In ActiveWorkbook.Worksheets
Select Case Sheet.Name
Case "Master Numbers"
'Ignore
Else
ActiveCell.Value = Sheet.Name
Cells(Cells.Row + 1, Cells.Column).Activate
End Select
Next

End Sub
--------------------


--
aking1987
------------------------------------------------------------------------
aking1987's Profile: http://www.excelforum.com/member.php...o&userid=15393
View this thread: http://www.excelforum.com/showthread...hreadid=314346



AA2e72E

Sub to aquire list of worksheets
 
The full solution (not e change from CElls.Row to ActiveCell.Row etc.):

Sub xx()
Range("A1").Select
For Each Sheet In ActiveWorkbook.Sheets
Select Case Sheet.Name
Case "EG1"
'Ignore
Case Else
ActiveCell.Value = Sheet.Name
Cells(ActiveCell.Row + 1, ActiveCell.Column).Activate
End Select
Next
End Sub



"AA2e72E" wrote:

Oops!

Replace the line

Else

by

Case Else

"aking1987" wrote:


AA2e72E Wrote:
Sub xx()
Range("A1").Select
For Each Sheet In ActiveWorkbook.Sheets
Select Case Sheet.Name
Case "EG1"
'Ignore
Else
ActiveCell.Value = Sheet.Name
Cells(Cells.Row + 1, Cells.Column).Activate
End Select
Next
End Sub


Else Without If


Code:
--------------------

Sub MacroAddNewFileListSheetNames()
' Creates a list of names of the sheets in SHEET Master Numbers, Column I (emitts Master Numbers)

Range("I1").Select
For Each Sheet In ActiveWorkbook.Worksheets
Select Case Sheet.Name
Case "Master Numbers"
'Ignore
Else
ActiveCell.Value = Sheet.Name
Cells(Cells.Row + 1, Cells.Column).Activate
End Select
Next

End Sub
--------------------


--
aking1987
------------------------------------------------------------------------
aking1987's Profile: http://www.excelforum.com/member.php...o&userid=15393
View this thread: http://www.excelforum.com/showthread...hreadid=314346



AA2e72E

Sub to aquire list of worksheets
 
!Same as below!

Sub xx()
Range("A1").Select
For Each Sheet In ActiveWorkbook.Sheets
Select Case Sheet.Name
Case "EG1"
'Ignore
Case Else
ActiveCell.Value = Sheet.Name
Cells(ActiveCell.Row + 1, ActiveCell.Column).Activate
End Select
Next
End Sub



"aking1987" wrote:


AA2e72E Wrote:
Sub xx()
Range("A1").Select
For Each Sheet In ActiveWorkbook.Sheets
Select Case Sheet.Name
Case "EG1"
'Ignore
Else
ActiveCell.Value = Sheet.Name
Cells(Cells.Row + 1, Cells.Column).Activate
End Select
Next
End Sub


Else Without If


Code:
--------------------

Sub MacroAddNewFileListSheetNames()
' Creates a list of names of the sheets in SHEET Master Numbers, Column I (emitts Master Numbers)

Range("I1").Select
For Each Sheet In ActiveWorkbook.Worksheets
Select Case Sheet.Name
Case "Master Numbers"
'Ignore
Else
ActiveCell.Value = Sheet.Name
Cells(Cells.Row + 1, Cells.Column).Activate
End Select
Next

End Sub
--------------------


--
aking1987
------------------------------------------------------------------------
aking1987's Profile: http://www.excelforum.com/member.php...o&userid=15393
View this thread: http://www.excelforum.com/showthread...hreadid=314346




All times are GMT +1. The time now is 03:51 PM.

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