ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Help (https://www.excelbanter.com/excel-programming/355552-code-help.html)

Shawn

Code Help
 
What is wrong with this code?

Dim xRange As Range
Dim xCell As Range

For Each xCell In Sheets("CDPTR").Range("A2:CA2")
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:=xlToRight <<<< Here I get an
error???

I used to have this set up to work on a column and it shifted deleted cells
up.

I need it to work on a row now, though, and to shift the deleted cells to
the right????


--
Thanks
Shawn

Jim Cone

Code Help
 
Shawn,

You can shift data up or to the left only...
xlShiftToLeft or xlShiftUp

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Shawn"
wrote in message
What is wrong with this code?

Dim xRange As Range
Dim xCell As Range

For Each xCell In Sheets("CDPTR").Range("A2:CA2")
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:=xlToRight <<<< Here I get an error???

I used to have this set up to work on a column and it shifted deleted cells up.
I need it to work on a row now, though, and to shift the deleted cells to
the right????
--
Thanks
Shawn

Ardus Petus

Code Help
 
xRange.Delete Shift:=xlToLeft

HTH
--
AP

"Shawn" a écrit dans le message de
...
What is wrong with this code?

Dim xRange As Range
Dim xCell As Range

For Each xCell In Sheets("CDPTR").Range("A2:CA2")
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:=xlToRight <<<< Here I get an
error???

I used to have this set up to work on a column and it shifted deleted

cells
up.

I need it to work on a row now, though, and to shift the deleted cells to
the right????


--
Thanks
Shawn





All times are GMT +1. The time now is 01:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com