![]() |
Searching Column and deleting cells -VBA
Very new to Excel programming and trying to develop a code snippet I can use
in differant ways. I need to examine the Cells in Column A for the fontstyle Italics or font size and if it matches the criteria delete them. This doesn't work: Dim cells As Object Dim rng As Range Set rng = Range("A1:A1000") For Each cells In rng If rng.cells.Font.FontStyle = "Italic" Then rng.cells.Value = "" End If Next cells What would? |
Searching Column and deleting cells -VBA
If you really want to delete the cell/row then loop backwards:
Dim rng As Range Dim r as Range, i as long Set rng = Range("A1:A1000") For i = rng(rng.count).row to rng(1).row step - 1 set r = cells(i,rng.column) If r.Font.Italic Then r.entirerow.Delete End If Next i Checking the Italic property of the font is easier than using Font Style. -- Regards, Tom Ogilvy "TLuebke" wrote: Very new to Excel programming and trying to develop a code snippet I can use in differant ways. I need to examine the Cells in Column A for the fontstyle Italics or font size and if it matches the criteria delete them. This doesn't work: Dim cells As Object Dim rng As Range Set rng = Range("A1:A1000") For Each cells In rng If rng.cells.Font.FontStyle = "Italic" Then rng.cells.Value = "" End If Next cells What would? |
Searching Column and deleting cells -VBA
Thanks Tom works like a champ!
"Tom Ogilvy" wrote: If you really want to delete the cell/row then loop backwards: Dim rng As Range Dim r as Range, i as long Set rng = Range("A1:A1000") For i = rng(rng.count).row to rng(1).row step - 1 set r = cells(i,rng.column) If r.Font.Italic Then r.entirerow.Delete End If Next i Checking the Italic property of the font is easier than using Font Style. -- Regards, Tom Ogilvy "TLuebke" wrote: Very new to Excel programming and trying to develop a code snippet I can use in differant ways. I need to examine the Cells in Column A for the fontstyle Italics or font size and if it matches the criteria delete them. This doesn't work: Dim cells As Object Dim rng As Range Set rng = Range("A1:A1000") For Each cells In rng If rng.cells.Font.FontStyle = "Italic" Then rng.cells.Value = "" End If Next cells What would? |
All times are GMT +1. The time now is 12:00 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com