Strike through

Peterfc2

Active Member
Joined
Jan 2, 2004
Messages
394
Office Version
  1. 2013
Platform
  1. Windows
How can I add strike through to all my workbook sheets if certain cell value found?
If the text Home is found then it should have strike though applied like Home
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Use
VBA Code:
Sub MM1()
Dim cel As Range, ws As Worksheet
For Each ws In Worksheets
    With ws
        For Each cel In .UsedRange
            If cel.Value = "Home" Then cel.Font.Strikethrough = True
        Next cel
    End With
Next ws
End Sub
 
Upvote 0
Works with a test wb but stops with
If cel.Value = "Home" Then etc on my main workbook
 
Upvote 0
I added wildcards "*Home*" hoping it would work on 'Home and Away' or 'Away and Home', it didn't.
 
Upvote 0
That is a completely different problem from what your first post hinted at (namely, that the cell value would be the word "Home"). Did you want to strikethrough all the text in the cell or just strikethrough the word "home"?
 
Upvote 0
Also,

1. Can you estimate how big the used range is on your sheets (rows x columns) and what percentage of cells might contain the word "Home"?

2. Do we have to look in all columns that contain data or might we only have to look at, say, columns B, F and J?

3. Is it possible that a cell could contain something like "Large Homes" where "Home" is part of a larger word and, if so, do you still want strikethrough?

4. What, exactly, do you mean by "stops"
Works with a test wb but stops with

5. Is it possible to have "home and away" and, if so, do you still want strikethrough?
 
Last edited:
Upvote 0
You didn't tell us it was a partial string.!!
Try using
VBA Code:
Sub MM1()
Dim cel As Range, ws As Worksheet, i As Integer, pos As Integer
For Each ws In Worksheets
    With ws
        For Each cel In .UsedRange
            For i = 0 To Len(cel.Value)
                pos = InStr(cel.Value, "Home")
                    If pos > 0 Then
                        cel.Characters(pos, Len("Home")).Font.Strikethrough = True
                    End If
            Next i
        Next cel
    End With
Next ws
End Sub
 
Upvote 0
Sorry for any confusion. MichaelM solution works perfectly. TY
 
Upvote 0

Forum statistics

Threads
1,214,544
Messages
6,120,126
Members
448,947
Latest member
test111

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