ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Goto Tab (https://www.excelbanter.com/excel-discussion-misc-queries/201347-goto-tab.html)

Ed Davis

Goto Tab
 
Is there a way for a macro to goto a Tab that is listed in a cel.
Example:

A5 has the name Jay and I want to goto the Jay tab.

Thanks in advance



Chip Pearson

Goto Tab
 
Ed,

Try code like

On Error Resume Next
With ThisWorkbook.Worksheets
.Item(.Item("Sheet1").Range("A5").Value).Select
End With
If Err.Number < 0 Then
MsgBox Err.Description
End If

It reads the contents of A5 on Sheet1 and activates the sheet named in that
cell.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"Ed Davis" wrote in message
...
Is there a way for a macro to goto a Tab that is listed in a cel.
Example:

A5 has the name Jay and I want to goto the Jay tab.

Thanks in advance




Ed Davis

Goto Tab
 
This workes great.
Thank You


"Chip Pearson" wrote in message
...
Ed,

Try code like

On Error Resume Next
With ThisWorkbook.Worksheets
.Item(.Item("Sheet1").Range("A5").Value).Select
End With
If Err.Number < 0 Then
MsgBox Err.Description
End If

It reads the contents of A5 on Sheet1 and activates the sheet named in
that cell.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"Ed Davis" wrote in message
...
Is there a way for a macro to goto a Tab that is listed in a cel.
Example:

A5 has the name Jay and I want to goto the Jay tab.

Thanks in advance





Rick Rothstein

Goto Tab
 
I know the OP has an answer, but I wanted to post (for the archives) a
method that does not require error checking...

Dim WS As Worksheet
For Each WS In Worksheets
If WS.Name = Worksheets("Sheet1").Range("A5").Value Then
WS.Select
Exit For
End If
Next

--
Rick (MVP - Excel)


"Ed Davis" wrote in message
...
Is there a way for a macro to goto a Tab that is listed in a cel.
Example:

A5 has the name Jay and I want to goto the Jay tab.

Thanks in advance





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

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