ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Bind VBA Variable to Range().Value2 Property (https://www.excelbanter.com/excel-programming/427099-how-bind-vba-variable-range-value2-property.html)

MachAngle

How to Bind VBA Variable to Range().Value2 Property
 
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?

Patrick Molloy[_2_]

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

Public Property Get MyValue() As Double
MyValue = Range("Cell.Reference").Value2
End Property


"MachAngle" wrote:

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?


Patrick Molloy[_2_]

How to Bind VBA Variable to Range().Value2 Property
 
create the property, then use it in your code exactly as if it were a
'normal' variable

eg

x= myvalue * 2



"Patrick Molloy" wrote:

Option Explicit

Public Property Get MyValue() As Double
MyValue = Range("Cell.Reference").Value2
End Property


"MachAngle" wrote:

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?


MachAngle

How to Bind VBA Variable to Range().Value2 Property
 
Looks straight forward.... Thanks!

"Patrick Molloy" wrote:

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

eg

x= myvalue * 2



"Patrick Molloy" wrote:

Option Explicit

Public Property Get MyValue() As Double
MyValue = Range("Cell.Reference").Value2
End Property


"MachAngle" wrote:

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?



All times are GMT +1. The time now is 10:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com