#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Delete Line

I need the code below altered so it deletes the entire row the blank cell is
in.

Dim xRange As Range
Dim xCell As Range

For Each xCell In Sheets("CDPTR").Range("A2:A25")
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Delete Line

Replace the last line of the code with

xRange.EntireRow.Delete

If this post helps click Yes
---------------
Jacob Skaria


"Shawn" wrote:

I need the code below altered so it deletes the entire row the blank cell is
in.

Dim xRange As Range
Dim xCell As Range

For Each xCell In Sheets("CDPTR").Range("A2:A25")
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Delete Line

Hi

Use this:

xRange.EntireRow.Delete

Regards,
Per

On 8 Maj, 14:03, Shawn wrote:
I need the code below altered so it deletes the entire row the blank cell is
in.

* * * * * * * * * * Dim xRange As Range
* * * * * * * * * * Dim xCell As Range

* * * * * * * * * * For Each xCell In Sheets("CDPTR").Range("A2:A25")
* * * * * * * * * * * * 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Delete Line

Great. That works. I was using this code and it wasn't working:

Range("xRange" & ActiveCell.Row).EntireRow.Delete Shift:=xlUp

--
Thanks
Shawn


"Jacob Skaria" wrote:

Replace the last line of the code with

xRange.EntireRow.Delete

If this post helps click Yes
---------------
Jacob Skaria


"Shawn" wrote:

I need the code below altered so it deletes the entire row the blank cell is
in.

Dim xRange As Range
Dim xCell As Range

For Each xCell In Sheets("CDPTR").Range("A2:A25")
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

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
Challenge - Excel Line Feed Character CHR(10) - How to Delete and keep the text formatting without going ro single line in a cell ? No Name Excel Worksheet Functions 7 October 7th 09 11:10 AM
Delete first line line(s) of text-file? Charlotte E.[_2_] Excel Programming 4 October 26th 08 08:31 AM
Delete all but first line Danu Excel Discussion (Misc queries) 3 October 18th 07 09:42 PM
Delete every other line Andy Excel Programming 2 November 15th 05 08:01 PM
Delete every other line Andy Excel Programming 0 November 15th 05 07:09 PM


All times are GMT +1. The time now is 07:19 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"