Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Double Double Quotes | Excel Programming | |||
double axis, double problem (i hope only to me) | Charts and Charting in Excel | |||
Delete row if double | Excel Discussion (Misc queries) | |||
Textboxes - restrict double-click and selection.delete | Excel Programming | |||
Generate permutations but delete double entries | Excel Programming |