Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete Rows question


I wish to get the following standard row-deletion code to be tweaked to
delete (not an enrireRow) but only rows across 3 columns - Columns A to
C.
I resorted to RESIZE method without success.

Sub DeleteRowsByCollection()

Dim c as Range
Dim rng as Range

For each c in Range("a1:a" & [a65536].End(xlUp).row)
If c.value = c.Offset(1,0).value Then
If rng Is Nothing Then
set rng = c.Resize(0,3) ========Application-defined or object-defined
error
Else
set rng = Union(rng, c.Resize(0,3))
End if
End if
Next

If not rng is Nothing then
rng.Delete
End if

End Sub

Deferring the RESIZING and applying it to the DELETE command as in
*rng.Resize(0,3).Delete * generates the same error.

TIA

Myles


--
Myles
------------------------------------------------------------------------
Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746
View this thread: http://www.excelforum.com/showthread...hreadid=522055

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Delete Rows question

not sure exactly what you want. but if you just want to delete the 3 columns and
the rng variable holds the values, then

rng.Delete Shift:=xlToLeft

will delete them and shift whatever is to the right of the deletion to the left

--


Gary


"Myles" wrote in message
...

I wish to get the following standard row-deletion code to be tweaked to
delete (not an enrireRow) but only rows across 3 columns - Columns A to
C.
I resorted to RESIZE method without success.

Sub DeleteRowsByCollection()

Dim c as Range
Dim rng as Range

For each c in Range("a1:a" & [a65536].End(xlUp).row)
If c.value = c.Offset(1,0).value Then
If rng Is Nothing Then
set rng = c.Resize(0,3) ========Application-defined or object-defined
error
Else
set rng = Union(rng, c.Resize(0,3))
End if
End if
Next

If not rng is Nothing then
rng.Delete
End if

End Sub

Deferring the RESIZING and applying it to the DELETE command as in
*rng.Resize(0,3).Delete * generates the same error.

TIA

Myles


--
Myles
------------------------------------------------------------------------
Myles's Profile:
http://www.excelforum.com/member.php...o&userid=28746
View this thread: http://www.excelforum.com/showthread...hreadid=522055



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Delete Rows question

sorry, if you're deleting rows


rng.Delete Shift:=xlUp

--


Gary


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
not sure exactly what you want. but if you just want to delete the 3 columns
and the rng variable holds the values, then

rng.Delete Shift:=xlToLeft

will delete them and shift whatever is to the right of the deletion to the
left

--


Gary


"Myles" wrote in message
...

I wish to get the following standard row-deletion code to be tweaked to
delete (not an enrireRow) but only rows across 3 columns - Columns A to
C.
I resorted to RESIZE method without success.

Sub DeleteRowsByCollection()

Dim c as Range
Dim rng as Range

For each c in Range("a1:a" & [a65536].End(xlUp).row)
If c.value = c.Offset(1,0).value Then
If rng Is Nothing Then
set rng = c.Resize(0,3) ========Application-defined or object-defined
error
Else
set rng = Union(rng, c.Resize(0,3))
End if
End if
Next

If not rng is Nothing then
rng.Delete
End if

End Sub

Deferring the RESIZING and applying it to the DELETE command as in
*rng.Resize(0,3).Delete * generates the same error.

TIA

Myles


--
Myles
------------------------------------------------------------------------
Myles's Profile:
http://www.excelforum.com/member.php...o&userid=28746
View this thread: http://www.excelforum.com/showthread...hreadid=522055





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete Rows question


Thanks Gary.

But the issue is not addresed by the directional shift keys upon
deleting.
Altering *rng.Delete* to *rng.Delete Shift:=xlUP* (and omitting the
RESIZE qualification) willl leave columns B and C intact and that is
not desired.

myles


--
Myles
------------------------------------------------------------------------
Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746
View this thread: http://www.excelforum.com/showthread...hreadid=522055

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
Delete Duplicate Rows Macro Question elfmajesty Excel Discussion (Misc queries) 1 June 17th 06 01:12 AM
Quick Macro question - How to delete two rows then skip one - and repeat David Smithz Excel Discussion (Misc queries) 3 March 3rd 06 02:58 PM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM
Annoying delete empty rows question Tamsen Excel Programming 5 September 5th 03 03:39 AM


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