Delete rows if

Giancar

Board Regular
Joined
Nov 29, 2017
Messages
52
Hi everyone,

Which is the VBA code to delete in the Active worksheet, all the rows that contains in Column D words in strikethrough format?
Weird thing: when I try to find words strikethrough format through "find and replace" button, I have no results.
I am really struggling.

Thank you
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Give this a go
Code:
Sub DeletRowWithStrikethrough()
   With Columns("D:D")
      With .Application.FindFormat
         .Clear
         .Font.Strikethrough = True
      End With
      .Replace "", "", xlPart, , , , True, False
      .Application.FindFormat.Clear
      .SpecialCells(xlBlanks).EntireRow.Delete
   End With
End Sub
It will only work if the entire cell has strikethrough. Also it will delete any rows where the cell in col D is blank. If that won't work for you let me know
 
Upvote 0
Give this a go
Code:
Sub DeletRowWithStrikethrough()
   With Columns("D:D")
      With .Application.FindFormat
         .Clear
         .Font.Strikethrough = True
      End With
      .Replace "", "", xlPart, , , , True, False
      .Application.FindFormat.Clear
      .SpecialCells(xlBlanks).EntireRow.Delete
   End With
End Sub
It will only work if the entire cell has strikethrough. Also it will delete any rows where the cell in col D is blank. If that won't work for you let me know

Hey, you helped me a lot, but still not the result I wished.
This code delete the empty rows (something that I do not need, but it is fine as I never have empty rows) but it seems not affecting the strikethrough rows.
The worksheet it is a google sheet doc converted in a Excel doc, so not sure that is strikethrough in that way (not sure I am clear).
Thank you
 
Upvote 0
If it's been converted, that may well be the problem.
As I've never used Google Sheets, I'm unable to offer any further help.
 
Upvote 0
The worksheet it is a google sheet doc converted in a Excel doc, so not sure that is strikethrough in that way (not sure I am clear).
Select a cell with what you think is strikethrough font, press CTRL+1 to bring up the "Format Cells" dialog box, select the "Font" tab and then look at the "Effects" panel... is there a check mark in the "Strikethrough" checkbox?
 
Last edited:
Upvote 0
Select a cell with what you think is strikethrough font, press CTRL+1 to bring up the "Format Cells" dialog box, select the "Font" tab and then look at the "Effects" panel... is there a check mark in the "Strikethrough" checkbox?

No, it's not selected. Can we find an alternative way?
Basically the Column D is "strikethrough" if Column F is before today (but then I think I have a different problem because the date is in this format: 19/12/2017 04:59:00)

I am really desperate...too much for my skills :(
 
Upvote 0
Assuming that this is connected to this https://www.mrexcel.com/forum/excel...leting-rows-multiple-sheet-2.html#post4973186
Try
Code:
Sub DelRows()

   Dim UsdRws As Long
   Dim Ws As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
    
   For Each Ws In Sheets(Array("FR", "IT", "ES"))
      If Ws.AutoFilterMode Then Ws.AutoFilterMode = False
      UsdRws = Ws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
      Ws.Range("A2:AR2").AutoFilter Field:=6, Criteria1:="<" & CLng(Date)
      Ws.Range("F3:F" & UsdRws).SpecialCells(xlCellTypeVisible).EntireRow.Delete
      Ws.ShowAllData
   Next Ws
   
Application.Calculation = xlCalculationAutomatic
End Sub
 
Upvote 0
No, it's not selected. Can we find an alternative way?
Basically the Column D is "strikethrough" if Column F is before today (but then I think I have a different problem because the date is in this format: 19/12/2017 04:59:00)
Ahh, your strikethrough is the result of Conditional Formatting then, correct? If so, that is why you cannot see the font as being strikethough... Conditional Formatting is not "real" formatting per se, rather, it is variable formatting that gets overlaid on top of the cells real format. See if the following does what you want...
Code:
Sub DeleteStrikeThroughRows()
  Dim Cell As Range
  For Each Cell In Range("D1", Cells(Rows.Count, "D").End(xlUp))
    If Cell.DisplayFormat.Font.Strikethrough Then Cell.Value = "#N/A"
  Next
  On Error Resume Next
  Columns("D").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
End Sub
 
Upvote 0
Nice spot Rick, I was wondering how it got there.
 
Upvote 0
Assuming that this is connected to this https://www.mrexcel.com/forum/excel...leting-rows-multiple-sheet-2.html#post4973186
Try
Code:
Sub DelRows()

   Dim UsdRws As Long
   Dim Ws As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
    
   For Each Ws In Sheets(Array("FR", "IT", "ES"))
      If Ws.AutoFilterMode Then Ws.AutoFilterMode = False
      UsdRws = Ws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
      Ws.Range("A2:AR2").AutoFilter Field:=6, Criteria1:="<" & CLng(Date)
      Ws.Range("F3:F" & UsdRws).SpecialCells(xlCellTypeVisible).EntireRow.Delete
      Ws.ShowAllData
   Next Ws
   
Application.Calculation = xlCalculationAutomatic
End Sub

This is working!!! So at the end you worked on the date! Thanks
Just a quick top up on your code: is it possible to delete also rows that contain "#N/A" in column D?

That is a Gdoc that has been created by someone else following their rules, nothing that I can change :(
 
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,612
Members
452,661
Latest member
Nonhle

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