ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check if more than one font is used in a cell? (https://www.excelbanter.com/excel-programming/282736-check-if-more-than-one-font-used-cell.html)

Handler Robert

Check if more than one font is used in a cell?
 

Is there a way to find out, if more than one font is used in a cell?

The example below shows how to use different fonts in one cell.
I need to test if this is done and if it is done to get the differen
font objects.

Range("B5").Select
ActiveCell.FormulaR1C1 = "abcdef"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Superscript = False
End With
With ActiveCell.Characters(Start:=3, Length:=1).Font
.Superscript = True
End With
With ActiveCell.Characters(Start:=4, Length:=3).Font
.Superscript = False
End With
Range("B6").Selec

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com


Vic Eldridge

Check if more than one font is used in a cell?
 
You'd need to loop through all the characters using the Characters object.
The following code should get you started.


For i = 1 To Range("B5").Characters.Count
With Range("B5").Characters(i, 1).Font
MsgBox "Character " & vbTab & .Parent.Text & vbCrLf & _
"Color " & vbTab & .Color & vbCrLf & _
"Bold " & vbTab & .Bold & vbCrLf & _
"Superscript " & vbTab & .Superscript & vbCrLf & _
"Name " & vbTab & .Name
'etc
End With
Next i


Regards,
Vic Eldridge


Handler Robert wrote in message ...
Is there a way to find out, if more than one font is used in a cell?

The example below shows how to use different fonts in one cell.
I need to test if this is done and if it is done to get the different
font objects.

Range("B5").Select
ActiveCell.FormulaR1C1 = "abcdef"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Superscript = False
End With
With ActiveCell.Characters(Start:=3, Length:=1).Font
.Superscript = True
End With
With ActiveCell.Characters(Start:=4, Length:=3).Font
.Superscript = False
End With
Range("B6").Select


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


Dave Peterson[_3_]

Check if more than one font is used in a cell?
 
Just to check to see if there's more than one Font:

Option Explicit

Sub testme01()

Dim myFont As Variant
myFont = ActiveSheet.Range("a1").Font.Name
If IsNull(myFont) Then
MsgBox "multiple fonts"
Else
MsgBox "only one and it's: " & myFont
End If

End Sub

Not sure what you're doing, but here's a link that may give you an idea:

http://www.google.com/groups?threadm...ECE4%40msn.com

Handler Robert wrote:

Is there a way to find out, if more than one font is used in a cell?

The example below shows how to use different fonts in one cell.
I need to test if this is done and if it is done to get the different
font objects.

Range("B5").Select
ActiveCell.FormulaR1C1 = "abcdef"
With ActiveCell.Characters(Start:=1, Length:=2).Font
Superscript = False
End With
With ActiveCell.Characters(Start:=3, Length:=1).Font
Superscript = True
End With
With ActiveCell.Characters(Start:=4, Length:=3).Font
Superscript = False
End With
Range("B6").Select

------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


--

Dave Peterson


Handler Robert[_2_]

Check if more than one font is used in a cell?
 

Thanks for your answers.

With a combinatin of your answers,
I can first check, If a cell contains multiple fonts
and if yes, i have to check each character

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com



All times are GMT +1. The time now is 03:59 PM.

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