ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Properties returning object reference or value? (https://www.excelbanter.com/excel-programming/428429-properties-returning-object-reference-value.html)

[email protected]

Properties returning object reference or value?
 
In the Help for Font Object, there is this example code:

Worksheets("Sheet1").Range("A1:C5").Font.Bold = True

The help also says that the Font property returns a Font object.
Assuming that the property returns a value rather than a reference,
I'm imagining an actual construct that exists apart from the range
itself, containing fields that describe the font(s) used within the
range. I'm trying to understand how assigning a True to one of the
member fields in the Font object (the Bold field) causes True to be
propagated back to the actual range cells. In C++ vernacular, has the
assignment operator "=" been overriden?

Thanks

JLGWhiz[_2_]

Properties returning object reference or value?
 
Bold is a property of the Font object. The Boolean value of Bold is either
True or False. It has nothing to do with the Range Object.



wrote in message
...
In the Help for Font Object, there is this example code:

Worksheets("Sheet1").Range("A1:C5").Font.Bold = True

The help also says that the Font property returns a Font object.
Assuming that the property returns a value rather than a reference,
I'm imagining an actual construct that exists apart from the range
itself, containing fields that describe the font(s) used within the
range. I'm trying to understand how assigning a True to one of the
member fields in the Font object (the Bold field) causes True to be
propagated back to the actual range cells. In C++ vernacular, has the
assignment operator "=" been overriden?

Thanks




Patrick Molloy

Properties returning object reference or value?
 
Function emboldened(target As Range) As Boolean
Application.Volatile
On Error Resume Next
emboldened = target.Font.Bold '= True
If Err.Number < 0 Then
emboldened = False
End If
On Error GoTo 0
End Function

this UDF actually returns TRUE if all the cells in the selected Range have
their FONT Emboldened set to TRUE
The error trap is required since a #Value is returned if some but not all
cells in the passed range have this.




wrote in message
...
In the Help for Font Object, there is this example code:

Worksheets("Sheet1").Range("A1:C5").Font.Bold = True

The help also says that the Font property returns a Font object.
Assuming that the property returns a value rather than a reference,
I'm imagining an actual construct that exists apart from the range
itself, containing fields that describe the font(s) used within the
range. I'm trying to understand how assigning a True to one of the
member fields in the Font object (the Bold field) causes True to be
propagated back to the actual range cells. In C++ vernacular, has the
assignment operator "=" been overriden?

Thanks




All times are GMT +1. The time now is 11:14 AM.

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