LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Delete rows with 0 in target cell

Below is a handy code I have used to serch a range and delete all cells with
a 0. I need to modify this slightly so it will not only delete the cells
with 0, but all the cells with 0 along with the four cells to the left of
that cell. For example, if cell F5 has a 0 in it, it will delete cells A5:F5.

Dim xRange As Range
Dim xCell As Range

For Each xCell In Sheets("SDII").Range("F2:F34")
If xCell.Value = 0 Then
If xRange Is Nothing Then
Set xRange = xCell
Else
Set xRange = Union(xRange, xCell)
End If
End If
Next xCell
xRange.Delete Shift:=xlUp



--
Thanks
Shawn
 
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
Target Address Property for Insert/Delete Row/Column Excel Monkey[_2_] Excel Programming 1 April 20th 09 08:03 PM
Writing a Macro to Find & Delete Target Rows in a Range djd011 Excel Programming 3 November 16th 07 09:07 PM
Delete Rows if any cell in Column H is blank but do not Delete Fir manfareed Excel Programming 4 September 28th 07 05:20 PM
Target cell reference moves when target is cut and pasted Illya Teideman Excel Discussion (Misc queries) 5 May 31st 07 11:34 AM
Deleting Rows from using a target cell Mike[_43_] Excel Programming 1 August 11th 03 06:19 PM


All times are GMT +1. The time now is 09:07 AM.

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

About Us

"It's about Microsoft Excel"