简体   繁体   中英

How can I active a specific worksheet based on a variable. The variable will have the name of the desired Sheet to activate

I need to activate a different Sheet on different times. The Sheet I will need to activate will vary based on a cell value (C2). Cell value (C2) in the Sheet named "Report" will contain the name of the Sheet. Can't get to get it done ...

I am trying this, I read elsewhere:

Sheets(Sheets("Report").Range("C2")).Activate

I get:

Run-time error '13' Type mismatch

Try:

WorkSheets(WorkSheets("Report").Range("C2").Value).Activate

Working:

在此处输入图片说明

Maybe you can try this :

ThisWorkbook.Sheets(Sheets("Sheet1").Range("C2").Value).Activate

Your code would have work to if you added .Value

Sheets(Sheets("Sheet1").Range("A2").Value).Activate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM