How to Bind VBA Variable to Range().Value2 Property

  • Thread starter Thread starter MachAngle
  • Start date Start date
M

MachAngle

I want to use Excel VBA variables in modules and classes as "shorthand" for
the Range().Value2 property. I tried using declarations like:

Dim Variable As Double
Set Variable = Range("Cell Reference").Value2

Is there some way to use data binding in VBA to "link" a variable to a Named
cell property?
 
Option Explicit

Public Property Get MyValue() As Double
MyValue = Range("Cell.Reference").Value2
End Property
 
create the property, then use it in your code exactly as if it were a
'normal' variable

eg

x= myvalue * 2
 
Looks straight forward.... Thanks!

Patrick Molloy said:
create the property, then use it in your code exactly as if it were a
'normal' variable

eg

x= myvalue * 2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top