ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Define sheet name then select sheet (https://www.excelbanter.com/excel-discussion-misc-queries/169521-define-sheet-name-then-select-sheet.html)

merry_fay

Define sheet name then select sheet
 
Hiya,

I've typed the name of the sheet I want to go to in a cell in excel & used
the macro to define it, but then I can't seem to get the code right for using
that definition to activate the sheet.

sheet_name = ActiveCell.Value
Sheet sheet_name.Select (I've tried lots of different ways of writing this...)

Can anyone help?

Thanks
merry_fay

Chip Pearson

Define sheet name then select sheet
 
Try

ThisWorkbook.Sheets(sheet_name).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"merry_fay" wrote in message
...
Hiya,

I've typed the name of the sheet I want to go to in a cell in excel & used
the macro to define it, but then I can't seem to get the code right for
using
that definition to activate the sheet.

sheet_name = ActiveCell.Value
Sheet sheet_name.Select (I've tried lots of different ways of writing
this...)

Can anyone help?

Thanks
merry_fay



Carim

Define sheet name then select sheet
 
Hi,

Just try :

Dim sheet_name As String
sheet_name = ActiveCell.Value
Sheets(sheet_name).Select

HTH

Don Guillett

Define sheet name then select sheet
 
Sub selectsheetfromcellvalue()
Sheets(ActiveCell.Value).Select
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"merry_fay" wrote in message
...
Hiya,

I've typed the name of the sheet I want to go to in a cell in excel & used
the macro to define it, but then I can't seem to get the code right for
using
that definition to activate the sheet.

sheet_name = ActiveCell.Value
Sheet sheet_name.Select (I've tried lots of different ways of writing
this...)

Can anyone help?

Thanks
merry_fay




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

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