Code Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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????
 
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" <[email protected]>
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????
 
Back
Top