COUNT italics

Sigh

Active Member
Joined
Oct 24, 2007
Messages
379
Is it possible to COUNT based on the font style of a cell? I want to count the number of cells in italics if possible.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Sure. You can determine whether a certain cell has a specific style with
Code:
If Range("A1").Font.Italic = True Then

You can use this in a loop that goes through your whole range.

Code:
For each cl in Range("A1:D1")
    If cl.Font.Italic = True Then
         i =i+1
    End If
Next cl

Then you could display the counted cells in variable i when the loop is finished

Code:
MsgBox "The number of Italic style cells in the range is " & i
 
Last edited:
Upvote 0
Hi, thanks for your response. When I run this I get 'invalid outside procedure', I must be doing something wrong...
 
Upvote 0
Try:
Code:
Public Function Count_Italic(Rng As Range) As Long
Dim Cel As Range
Application.Volatile
For Each Cel In Rng
    If Cel.Font.Italic = True Then
         Count_Italic = Count_Italic + 1
    End If
Next Cel
End Function
 
Upvote 0
Thanks Phuoc but I get 'Expected End Sub' error. Also where in the code to I type the range? Sorry for the basic question.
 
Upvote 0
You must be unfamiliar with VBA. Please look up some literature and familiarise yourself with basic VBA

A sub must always start with Sub NAME ()
and end with End Sub
 
Upvote 0
You're right, I am unfamiliar with VBA, trouble is I need a quick solution, I will take a tutorial when I'm less busy.
 
Upvote 0
Simply conjoin the last two of my scripts into a single sub.
Other than that, Phuoc's function works the same and can be used as a formula in your worksheet.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top