Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Any way to count cells contining one, or more STRIKETHROUGHS?

Worked for me as well, thank you very much.


You could always check to see if there was anything in the cell:

Option Explicit
Function CountStrikeThrough(myRng As Range) As Long

Application.Volatile

Dim myCell As Range
Dim ctr As Long

ctr = 0
For Each myCell In myRng.Cells
If myCell.Value = "" Then
'do nothing
Else
If myCell.Font.Strikethrough = True Then
ctr = ctr + 1
End If
End If
Next myCell

CountStrikeThrough = ctr

End Function

But as a generic routine, I'm not sure which I'd want.


Biff wrote:

Maybe a little nit-picky, but.........

This doesn't account for empty cells. It counts cells that are formatted but
may be empty.

Example:

Format cells A1:A10 for strikethrough. Don't enter anything in those cells.

=CountStrikeThrough(A1:A10) returns 10

Biff

"Dave Peterson" wrote in message
...
A UDF solution:

Option Explicit
Function CountStrikeThrough(myRng As Range) As Long

Application.Volatile

Dim myCell As Range
Dim ctr As Long

ctr = 0
For Each myCell In myRng.Cells
If myCell.Font.Strikethrough = True Then
ctr = ctr + 1
End If
Next myCell

CountStrikeThrough = ctr

End Function


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.

Then use a formula like:

=countstrikethrough(a1:a20)

Be aware that changing the format won't make this function recalculate.
You'll
want to force a recalc before you trust the results.

Father Guido wrote:

Hi,

I'm using XL2002 and am looking to count the number of cells in a
column that have words struck out. In my case all the words in each
cell are either all struck out, or none are struck out.

First I can't figure out what character a strikethrough is, anyone
know? And I can't get the CODE because excel will only return the code
for the first character in a cell, which is nothing when there is
nothing in the cell, even if you pre-select strikethrough from format
cells.

In the end I'm looking to make an array formula that will tell me how
many cells have a strikethrough AND match another condition.

I would be very happy just counting the first character of the cells
if that makes life any easier.

Preferably I'm looking for a formula to do this, but will settle for a
VBA solution if necessary. 8^)

Thanks,

Norm

--

Dave Peterson


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count # of cells b/w cells ... AriBari Excel Discussion (Misc queries) 4 July 18th 05 09:26 PM
count cells that have *text1* and don't have *text2* amntre Excel Discussion (Misc queries) 1 April 6th 05 12:50 PM
Count cells in a column that contain dates Cachod1 New Users to Excel 1 March 29th 05 08:56 PM
Count cells in one range based on parameters in another range dave roth Excel Worksheet Functions 2 March 29th 05 05:33 PM
How do I count shaded cells Randy Excel Worksheet Functions 19 February 3rd 05 11:35 PM


All times are GMT +1. The time now is 09:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"