ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using VBA in Excel to locate a sheet (https://www.excelbanter.com/excel-programming/382427-using-vba-excel-locate-sheet.html)

[email protected]

Using VBA in Excel to locate a sheet
 
I want to set up a code to read the contents of a cell and locate the
sheet that matches what's in the cell. For example, if the cell reads
"Home", I want it to locate and open the worksheet named Home. How do
I do this?


JMay

Using VBA in Excel to locate a sheet
 
Sub foo()
Dim MySheet As String
On Error GoTo errhandler
MySheet = Range("A1").Value
Worksheets(MySheet).Activate
Exit Sub
errhandler:
MsgBox "There is no worksheet by this name"
End Sub

" wrote in
message oups.com:

I want to set up a code to read the contents of a cell and locate the
sheet that matches what's in the cell. For example, if the cell reads
"Home", I want it to locate and open the worksheet named Home. How do
I do this?




All times are GMT +1. The time now is 02:01 PM.

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