View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default VBA - How to "execute" a dynamic variable assignment

Dim MyVar 'as variant so it can hold any 'type' of data

'Assign cell values this way...

Sub Test()
Dim MyVar
MyVar = [a2].Value: Debug.Print MyVar
MyVar = [a3].Value: Debug.Print MyVar
MyVar = Empty: Debug.Print MyVar
MyVar = 123: Debug.Print MyVar
End Sub

...results in Immediate Window:

Purple
String

123

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus