Properties returning object reference or value?

P

paul.domaskis

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
 
J

JLGWhiz

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.
 
P

Patrick Molloy

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.
 

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

Top