Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identify Cell with Single Underline 2

Status
Not open for further replies.
Jun 5, 2002
417
AU
Hi,

I have this function to identify cells with formulas:

Code:
Function HasFormula(Check_Cell As Range)
'
' HasFormula Function
' Checks whether a cell has a formula - TRUE/FALSE
' =HasFormula(A1)
'
    HasFormula = Check_Cell.HasFormula
End Function

I would like something virtually identical to identify if a cell has a single Underline, as ther does not appear to be a "HasUnderline" reference in VBA.

Any help greatly appreciated.

Thanks,

Peter Moran
 


hi,

Functions return values not formats.

However, your requirement can be quite easily done using Excel's native Conditional Formatting feature. Use your HasFormula function in the CF formula and format your CF as required.

No additional VBA required.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
You'd use something like:
Code:
If Check_Cell.Font.Underline = 2 Then
in your code.


Cheers, Glenn.

Beauty is in the eye of the beerholder.
 



Boy I missed that one!

You might have ALL the characters underlined or only SOME of the characters underlined. It's a bit different than a formula, which for a cell is binary.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Like this ?
Code:
Function IsUnderlined(Check_Cell As Range)
    IsUnderlined = (Check_Cell.Font.Underline = xlUnderlineStyleSingle
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OOps, missed closing paren.
Code:
Function IsUnderlined(Check_Cell As Range)
    IsUnderlined = (Check_Cell.Font.Underline = xlUnderlineStyleSingle)
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,

Thanks Skip and GlennUK.

Used GlennUK's code

Much appreciated.

Peter Moran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top