Statement always true even when it's not

rjwebgraphix

Well-known Member
Joined
May 25, 2010
Messages
590
Can someone help me out with this? I'm just trying to hide rows that the font is strikethrough, but the following code acting as if every row is strikethrough. Some are, some are not. *scratching head*

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


Dim lastrow As Long
Dim i As Long


lastrow = Cells(Rows.Count, "A").End(xlUp).Row


For i = 1 To lastrow
    If Cells(lastrow, "A").Characters.Font.Strikethrough = True Then
        Rows(i).EntireRow.Hidden = True
    Else
        Rows(i).EntireRow.Hidden = False
    End If
Next i


End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Nevermind, I found it. Brain dead today....

Code:
If Cells(i, "A").Characters.Font.Strikethrough = True Then
 
Upvote 0
Try replacing this:

Cells(lastrow, "A")

with this:

Cells(i, "A")
 
Upvote 0
You could replace

Code:
  If Cells(i, "A").Characters.Font.Strikethrough = True Then
    Rows(i).EntireRow.Hidden = True
  Else
    Rows(i).EntireRow.Hidden = False
  End If

With
Code:
    Rows(i).Hidden = Cells(i, "A").Characters.Font.Strikethrough
 
Upvote 0

Forum statistics

Threads
1,213,520
Messages
6,114,099
Members
448,548
Latest member
harryls

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