excel vba - VBA: Get name of variable -
is there function or property variables name? something like msgbox myvariable.name or msgbox nameofvariable(myvariable) that returns "myvariable" when defined e.g. myvariable = "whatever" ? google brings questions variable referencing... a possible class approach following (commented): add class module in vba ide click insert-> class module click view -> property window enter (name) property textbox , type in "variable" (or whatever may prefer consistent in following steps) enter following code in class code pane option explicit 'declare fields attached every instance of class public name string '<--| store name of variable you'll set object of class public value variant '<--| store value associated variable you'll set object of class 'declare `method` write `value` of object in named range named after `name` field sub writerange(optional wb variant) '<--| can pass referen...