View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
TLuebke TLuebke is offline
external usenet poster
 
Posts: 4
Default 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?