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

I have this macro

Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("D" & r)
If c.Value = "Back" Then
c.EntireRow.Delete
End If
Next r

What can I add to this macro so that it in addition to deleting the entire
row if it finds "Back" in Column D, it also deletes the entire row above it?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Double Delete

try this

Range(c, c.Offset(-1, 0)).EntireRow.Delete


On Apr 2, 8:40*pm, TGalin wrote:
I have this macro

Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("D" & r)
If c.Value = "Back" Then
c.EntireRow.Delete
End If
Next r

What can I add to this macro so that it in addition to deleting the entire
row if it finds "Back" in Column D, it also deletes the entire row above it?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Double Delete

Change this line...

c.EntireRow.Delete

to this...

c.Offset(-1).Resize(2).EntireRow.Delete

--
Rick (MVP - Excel)


"TGalin" wrote in message
...
I have this macro

Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("D" & r)
If c.Value = "Back" Then
c.EntireRow.Delete
End If
Next r

What can I add to this macro so that it in addition to deleting the entire
row if it finds "Back" in Column D, it also deletes the entire row above
it?


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

Thank you. It worked.

"muddan madhu" wrote:

try this

Range(c, c.Offset(-1, 0)).EntireRow.Delete


On Apr 2, 8:40 pm, TGalin wrote:
I have this macro

Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("D" & r)
If c.Value = "Back" Then
c.EntireRow.Delete
End If
Next r

What can I add to this macro so that it in addition to deleting the entire
row if it finds "Back" in Column D, it also deletes the entire row above it?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Double Delete

You were correct. I tested it. Thank you.

"Rick Rothstein" wrote:

Change this line...

c.EntireRow.Delete

to this...

c.Offset(-1).Resize(2).EntireRow.Delete

--
Rick (MVP - Excel)


"TGalin" wrote in message
...
I have this macro

Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("D" & r)
If c.Value = "Back" Then
c.EntireRow.Delete
End If
Next r

What can I add to this macro so that it in addition to deleting the entire
row if it finds "Back" in Column D, it also deletes the entire row above
it?



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
Double Double Quotes [email protected] Excel Programming 5 June 20th 07 02:14 PM
double axis, double problem (i hope only to me) kitcho Charts and Charting in Excel 1 December 30th 06 12:52 AM
Delete row if double bahri Excel Discussion (Misc queries) 2 August 5th 06 04:20 PM
Textboxes - restrict double-click and selection.delete [email protected] Excel Programming 0 May 18th 06 09:07 PM
Generate permutations but delete double entries as_sass[_11_] Excel Programming 3 April 12th 06 07:32 PM


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