#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default 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



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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Generic protect/unprotect code through buttons and code? StargateFanFromWork[_3_] Excel Programming 4 December 31st 05 12:10 AM
run code on opening workbook and apply code to certain sheets Jane Excel Programming 7 August 8th 05 09:15 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


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

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"