ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing listindex to worksheet names (https://www.excelbanter.com/excel-programming/300384-passing-listindex-worksheet-names.html)

David Adamson[_3_]

Passing listindex to worksheet names
 
Greetings all,



I'm trying to use the listindex to select a Worksheet. I don't want to use
value to set the worksheet name as the list values can be too long.



Worksheets names are "MD Catch 1", "MD Catch 2", "MD Catch 3", etc



I just can't figure how to pass the index+1 to the name property



Any hints would be greatly appreciated.





Sub Sheet_Selections()

'sets the worksheet to use

Wsht = Area_Selection.Which_Catchment.ListIndex + 1



'worksheet to use

Alpha = Worksheets("MD Catch 1")



'other code

End Sub



Norman Jones

Passing listindex to worksheet names
 
Hi David,

You can use the Next property to return the next sheet object or any of its
properties, such as its name or index.

---
Regards,
Norman:

"David Adamson" wrote in message
...
Greetings all,



I'm trying to use the listindex to select a Worksheet. I don't want to

use
value to set the worksheet name as the list values can be too long.



Worksheets names are "MD Catch 1", "MD Catch 2", "MD Catch 3", etc



I just can't figure how to pass the index+1 to the name property



Any hints would be greatly appreciated.





Sub Sheet_Selections()

'sets the worksheet to use

Wsht = Area_Selection.Which_Catchment.ListIndex + 1



'worksheet to use

Alpha = Worksheets("MD Catch 1")



'other code

End Sub





Vasant Nanavati

Passing listindex to worksheet names
 
I'm not clear on the problem, but try:

Worksheets("MD Catch " & ListBox1.ListIndex + 1).Select

--

Vasant

"David Adamson" wrote in message
...
Greetings all,



I'm trying to use the listindex to select a Worksheet. I don't want to

use
value to set the worksheet name as the list values can be too long.



Worksheets names are "MD Catch 1", "MD Catch 2", "MD Catch 3", etc



I just can't figure how to pass the index+1 to the name property



Any hints would be greatly appreciated.





Sub Sheet_Selections()

'sets the worksheet to use

Wsht = Area_Selection.Which_Catchment.ListIndex + 1



'worksheet to use

Alpha = Worksheets("MD Catch 1")



'other code

End Sub





David Adamson[_3_]

Passing listindex to worksheet names
 
Vasant,

That works a treat thankyou very much!

David


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
I'm not clear on the problem, but try:

Worksheets("MD Catch " & ListBox1.ListIndex + 1).Select

--

Vasant




Tom Ogilvy

Passing listindex to worksheet names
 
Dim Wsht as Long
Dim Alpha as Worksheet
'sets the worksheet to use

Wsht = Area_Selection.Which_Catchment.ListIndex + 1

'worksheet to use

Set Alpha = Worksheets(Wsht)

Alpha.Activate

--
Regards,
Tom Ogilvy


"David Adamson" wrote in message
...
Greetings all,



I'm trying to use the listindex to select a Worksheet. I don't want to

use
value to set the worksheet name as the list values can be too long.



Worksheets names are "MD Catch 1", "MD Catch 2", "MD Catch 3", etc



I just can't figure how to pass the index+1 to the name property



Any hints would be greatly appreciated.





Sub Sheet_Selections()

'sets the worksheet to use

Wsht = Area_Selection.Which_Catchment.ListIndex + 1



'worksheet to use

Alpha = Worksheets("MD Catch 1")



'other code

End Sub






All times are GMT +1. The time now is 01:00 AM.

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