Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
VBA Code:
Dim ws_crp as worksheet
Dim ws_cwp as worksheet
x = "CRP"
Set ws_{x} = activeworkbook.worksheets(x)
Is it possible to build a variable name? I'm not quite sure of the VBA syntax to do so.
I want to build dynamic worksheet object variables based on the value of x. So if the value of x = "CRP", the object variable ws_crp would be created referring to worksheet("CRP"). If x = "CWP", the object variable ws_cwp would be created and set to refer to worksheet("CWP").