0

I am trying to open a worksheet that is a defined variable. I have a list of ID's and each of those ID's have their own worksheet where the name of the worksheet is the ID number. I am wanting to use the first ID value and assign it to a variable, then open the corresponding worksheet using that variable. Here is the current code I have. The error message is "Object Required".

    Dim proj As Range
    Dim Project As Range

    Set proj = Sheets("Project List").Range("B9")
    Set Project = proj.Value
    Sheets(Project).Activate

2 Answers 2

3

You are trying to put a value into an object. Also you should probably specify the workbook. Try instead:

Dim proj As Range
Dim Project As String

Set proj = ActiveWorkbook.Sheets("Project List").Range("B9")
Project = proj.Value
ActiveWorkbook.Sheets(Project).Activate
Sign up to request clarification or add additional context in comments.

Comments

0

you just need to convert the range into a string, which is what the argument needs to be for Sheets()

Dim proj As Range

Set proj = Worksheets("Project List").Range("B9")
Sheets(proj.Text).Activate

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.