Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formatting Cells and then deleting the reference column | Excel Worksheet Functions | |||
Deleting Duplicate Cells in one Column. | Excel Discussion (Misc queries) | |||
searching for and deleting duplicates | Excel Programming | |||
Deleting blank cells in a column | Excel Programming | |||
Deleting blank cells in a column | Excel Discussion (Misc queries) |