Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA - Using variable for wksht name

Status
Not open for further replies.

swtrader

IS-IT--Management
Dec 23, 2004
182
US
Dim S As String
S = ActiveSheet.Name

-- other code, going to different worksheet --

'trying to return to S

Sheets(S).Select -- doesn't work

What does work?

Thanks.



 


Hi,

The way I would do it...
Code:
Dim sSheetName As String
sSheetName = ActiveSheet.Name

' -- other code, going to different worksheet --

'trying to return to S

Sheets(sSheetName).Activate
But using the Select and Activate methods is not recommended in most cases. faq707-4105

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top