Need some help here, I've this excel macro to set the target worksheet (or reference to a worksheet with the name of "sheet2"
Set targetWS = Worksheets("sheet2")
My question is, what if I wanted to call out this "sheet2" from another worksheet with the name of "master", and the Cell A1, I have this sheet2 written there.
How should I rewrite my macro code for this case?
Set targetWS = ?
I've try many ways but still couldn't get it right. Can anyone help to shed some lights on this?
Thanks.
This worked for me:
Dim sh As String
Dim targetWS As Worksheet
sh = Worksheets("master").Range("A1")
Set targetWS = Worksheets(sh)
Debug.Print targetWS.Name
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.