Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Cells and then deleting the reference column Donna[_2_] Excel Worksheet Functions 3 May 2nd 09 04:56 PM
Deleting Duplicate Cells in one Column. Jamie Excel Discussion (Misc queries) 6 November 20th 07 04:40 PM
searching for and deleting duplicates Shandy720[_11_] Excel Programming 2 July 28th 06 12:12 PM
Deleting blank cells in a column bodhisatvaofboogie Excel Programming 1 June 13th 06 08:20 PM
Deleting blank cells in a column KatyLady Excel Discussion (Misc queries) 6 May 30th 05 03:47 PM


All times are GMT +1. The time now is 10:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"