Selecting a worksheet based on a cell value in Excel VBA

Issue

This Content is from Stack Overflow. Question asked by Tom

I am trying to select a particular page based on cell value U2. I am using the backend Excel names not the display names for the sheets. “Sheet11” is the sheet I am currently trying to connect to. I have tried the following codes, but getting run-time error 9, out of range.

What could I try next?

Thanks

#1
‘Dim ws As Worksheet
‘ws = Range(“U2”)
‘Set ws = ActiveSheet

#2
‘(Range(“U2”).Activate

#3
‘Sheet11.Activate
‘Works but no variable

#4
‘Sheets(Range(“U2”).Text).Activate

#5
‘Sheets(Range(“U2”).Value).Activate

#6
‘Dim GetString As String
‘GetString = Range(“U2”)
‘GetString.Activate



Solution

Check the Answers

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?