ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet Selected Names (https://www.excelbanter.com/excel-programming/279844-worksheet-selected-names.html)

Juraj[_2_]

Worksheet Selected Names
 
Hi,
I would like to get the list of names of worksheets which
are selected (marked with the mouse).

e.g.
I have 3 work sheets:
Table1
Table2
Table3
I select two of them Table1 and Table2. I am looking for
the code which gives me only this two names!!

To get all available worksheet names the following code
can be used:

For Each ws In Worksheets
MsgBox ws.Name
Next ws

Thank you for help.
Juraj.

keepITcool

Worksheet Selected Names
 

Juraj, try something like:

Sub ShowSelWorksheets()
Dim sh As Object
Dim s As String
For Each sh In ActiveWindow.SelectedSheets
If TypeName(sh) = "Worksheet" Then
s = s & sh.Name & vbNewLine
End If
Next
MsgBox s
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Juraj" wrote:

Hi,
I would like to get the list of names of worksheets which
are selected (marked with the mouse).

e.g.
I have 3 work sheets:
Table1
Table2
Table3
I select two of them Table1 and Table2. I am looking for
the code which gives me only this two names!!

To get all available worksheet names the following code
can be used:

For Each ws In Worksheets
MsgBox ws.Name
Next ws

Thank you for help.
Juraj.



KeepITCool

Worksheet Selected Names
 
Thanks a lot. It works very nice.

Juraj.
-----Original Message-----

Juraj, try something like:

Sub ShowSelWorksheets()
Dim sh As Object
Dim s As String
For Each sh In ActiveWindow.SelectedSheets
If TypeName(sh) = "Worksheet" Then
s = s & sh.Name & vbNewLine
End If
Next
MsgBox s
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Juraj" wrote:

Hi,
I would like to get the list of names of worksheets

which
are selected (marked with the mouse).

e.g.
I have 3 work sheets:
Table1
Table2
Table3
I select two of them Table1 and Table2. I am looking

for
the code which gives me only this two names!!

To get all available worksheet names the following code
can be used:

For Each ws In Worksheets
MsgBox ws.Name
Next ws

Thank you for help.
Juraj.


.



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

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