VBA Cut-Paste copies only one row and not all the rows
I am trying a code here to match all the cells of the "M" column in Sheet1 and Sheet3, and copy and delete all the rows from Sheet1 that contain any value from Sheet3's "M" column. Also, I want the records to get copied into "Sheet2" (all records to be deleted) However, it is deleting all the records but copying only the first row and not all the required rows. I tried some solutions I found online, but with no luck. Could anyone please suggest what might be the problem.
Below is the code:
Sub DeleteRows()
Dim rng As Range
Dim r As Long
Dim lr1 As Long
Dim lr3 As Long
Dim str As Variant
Dim i As Long: i = 1
Application.ScreenUpdating = False
lr3 = Sheets("Sheet3").Cells(Rows.Count, "M").End(xlUp).Row
Set rng = Sheets("Sheet3").Range("M2:M" & lr3)
lr1 = Sheets("Sheet1").Cells(Rows.Count, "M").End(xlUp).Row
For r = lr1 To 2 Step -1
str = Sheets("Sheet1").Cells(r, "M")
If Application.WorksheetFunction.CountIf(rng, str) > 0 Then
Sheets("Sheet1").Range(Cells(r, "A"), Cells(r, "N")).Cut Sheets("Sheet2").Cells(i, "A")
Sheets("Sheet1").Range(Cells(r, "A"), Cells(r, "N")).Delete (xlShiftUp)
i = i + 1
End If
Next r
Application.ScreenUpdating = True
End Sub
Appreciate your help! Thanks in advance!
excel vba excel-vba
|
show 1 more comment
I am trying a code here to match all the cells of the "M" column in Sheet1 and Sheet3, and copy and delete all the rows from Sheet1 that contain any value from Sheet3's "M" column. Also, I want the records to get copied into "Sheet2" (all records to be deleted) However, it is deleting all the records but copying only the first row and not all the required rows. I tried some solutions I found online, but with no luck. Could anyone please suggest what might be the problem.
Below is the code:
Sub DeleteRows()
Dim rng As Range
Dim r As Long
Dim lr1 As Long
Dim lr3 As Long
Dim str As Variant
Dim i As Long: i = 1
Application.ScreenUpdating = False
lr3 = Sheets("Sheet3").Cells(Rows.Count, "M").End(xlUp).Row
Set rng = Sheets("Sheet3").Range("M2:M" & lr3)
lr1 = Sheets("Sheet1").Cells(Rows.Count, "M").End(xlUp).Row
For r = lr1 To 2 Step -1
str = Sheets("Sheet1").Cells(r, "M")
If Application.WorksheetFunction.CountIf(rng, str) > 0 Then
Sheets("Sheet1").Range(Cells(r, "A"), Cells(r, "N")).Cut Sheets("Sheet2").Cells(i, "A")
Sheets("Sheet1").Range(Cells(r, "A"), Cells(r, "N")).Delete (xlShiftUp)
i = i + 1
End If
Next r
Application.ScreenUpdating = True
End Sub
Appreciate your help! Thanks in advance!
excel vba excel-vba
1
Bit hard to tell without seeing your data. Have you stepped through your code to see what's going on? You should add sheet references to all instances ofCells
.
– SJR
Nov 12 '18 at 19:07
If you're usingCut
, why do you need aDelete
line?
– dwirony
Nov 12 '18 at 19:08
@dwirony cut doesn't remove the line, it leaves an empty area
– Kubie
Nov 12 '18 at 19:10
@Kubie perhaps dwirony was implying keep the delete and drop the cut...
– Solar Mike
Nov 12 '18 at 19:14
@SolarMike good point, in that case can change thecut
to arange.value = range.value
– Kubie
Nov 12 '18 at 19:16
|
show 1 more comment
I am trying a code here to match all the cells of the "M" column in Sheet1 and Sheet3, and copy and delete all the rows from Sheet1 that contain any value from Sheet3's "M" column. Also, I want the records to get copied into "Sheet2" (all records to be deleted) However, it is deleting all the records but copying only the first row and not all the required rows. I tried some solutions I found online, but with no luck. Could anyone please suggest what might be the problem.
Below is the code:
Sub DeleteRows()
Dim rng As Range
Dim r As Long
Dim lr1 As Long
Dim lr3 As Long
Dim str As Variant
Dim i As Long: i = 1
Application.ScreenUpdating = False
lr3 = Sheets("Sheet3").Cells(Rows.Count, "M").End(xlUp).Row
Set rng = Sheets("Sheet3").Range("M2:M" & lr3)
lr1 = Sheets("Sheet1").Cells(Rows.Count, "M").End(xlUp).Row
For r = lr1 To 2 Step -1
str = Sheets("Sheet1").Cells(r, "M")
If Application.WorksheetFunction.CountIf(rng, str) > 0 Then
Sheets("Sheet1").Range(Cells(r, "A"), Cells(r, "N")).Cut Sheets("Sheet2").Cells(i, "A")
Sheets("Sheet1").Range(Cells(r, "A"), Cells(r, "N")).Delete (xlShiftUp)
i = i + 1
End If
Next r
Application.ScreenUpdating = True
End Sub
Appreciate your help! Thanks in advance!
excel vba excel-vba
I am trying a code here to match all the cells of the "M" column in Sheet1 and Sheet3, and copy and delete all the rows from Sheet1 that contain any value from Sheet3's "M" column. Also, I want the records to get copied into "Sheet2" (all records to be deleted) However, it is deleting all the records but copying only the first row and not all the required rows. I tried some solutions I found online, but with no luck. Could anyone please suggest what might be the problem.
Below is the code:
Sub DeleteRows()
Dim rng As Range
Dim r As Long
Dim lr1 As Long
Dim lr3 As Long
Dim str As Variant
Dim i As Long: i = 1
Application.ScreenUpdating = False
lr3 = Sheets("Sheet3").Cells(Rows.Count, "M").End(xlUp).Row
Set rng = Sheets("Sheet3").Range("M2:M" & lr3)
lr1 = Sheets("Sheet1").Cells(Rows.Count, "M").End(xlUp).Row
For r = lr1 To 2 Step -1
str = Sheets("Sheet1").Cells(r, "M")
If Application.WorksheetFunction.CountIf(rng, str) > 0 Then
Sheets("Sheet1").Range(Cells(r, "A"), Cells(r, "N")).Cut Sheets("Sheet2").Cells(i, "A")
Sheets("Sheet1").Range(Cells(r, "A"), Cells(r, "N")).Delete (xlShiftUp)
i = i + 1
End If
Next r
Application.ScreenUpdating = True
End Sub
Appreciate your help! Thanks in advance!
excel vba excel-vba
excel vba excel-vba
asked Nov 12 '18 at 19:02
SiddharthSiddharth
284
284
1
Bit hard to tell without seeing your data. Have you stepped through your code to see what's going on? You should add sheet references to all instances ofCells
.
– SJR
Nov 12 '18 at 19:07
If you're usingCut
, why do you need aDelete
line?
– dwirony
Nov 12 '18 at 19:08
@dwirony cut doesn't remove the line, it leaves an empty area
– Kubie
Nov 12 '18 at 19:10
@Kubie perhaps dwirony was implying keep the delete and drop the cut...
– Solar Mike
Nov 12 '18 at 19:14
@SolarMike good point, in that case can change thecut
to arange.value = range.value
– Kubie
Nov 12 '18 at 19:16
|
show 1 more comment
1
Bit hard to tell without seeing your data. Have you stepped through your code to see what's going on? You should add sheet references to all instances ofCells
.
– SJR
Nov 12 '18 at 19:07
If you're usingCut
, why do you need aDelete
line?
– dwirony
Nov 12 '18 at 19:08
@dwirony cut doesn't remove the line, it leaves an empty area
– Kubie
Nov 12 '18 at 19:10
@Kubie perhaps dwirony was implying keep the delete and drop the cut...
– Solar Mike
Nov 12 '18 at 19:14
@SolarMike good point, in that case can change thecut
to arange.value = range.value
– Kubie
Nov 12 '18 at 19:16
1
1
Bit hard to tell without seeing your data. Have you stepped through your code to see what's going on? You should add sheet references to all instances of
Cells
.– SJR
Nov 12 '18 at 19:07
Bit hard to tell without seeing your data. Have you stepped through your code to see what's going on? You should add sheet references to all instances of
Cells
.– SJR
Nov 12 '18 at 19:07
If you're using
Cut
, why do you need a Delete
line?– dwirony
Nov 12 '18 at 19:08
If you're using
Cut
, why do you need a Delete
line?– dwirony
Nov 12 '18 at 19:08
@dwirony cut doesn't remove the line, it leaves an empty area
– Kubie
Nov 12 '18 at 19:10
@dwirony cut doesn't remove the line, it leaves an empty area
– Kubie
Nov 12 '18 at 19:10
@Kubie perhaps dwirony was implying keep the delete and drop the cut...
– Solar Mike
Nov 12 '18 at 19:14
@Kubie perhaps dwirony was implying keep the delete and drop the cut...
– Solar Mike
Nov 12 '18 at 19:14
@SolarMike good point, in that case can change the
cut
to a range.value = range.value
– Kubie
Nov 12 '18 at 19:16
@SolarMike good point, in that case can change the
cut
to a range.value = range.value
– Kubie
Nov 12 '18 at 19:16
|
show 1 more comment
1 Answer
1
active
oldest
votes
Well here's your almost exact same code just added With
blocks and .
's because that might've been the problem
Sub DeleteRows()
Dim rng As Range
Dim r As Long
Dim lr1 As Long
Dim lr3 As Long
Dim str As Variant
Dim i As Long: i = 1
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("Sheet3")
lr3 = .Cells(.Rows.Count, "M").End(xlUp).Row
Set rng = .Range("M2:M" & lr3)
End With
With ThisWorkbook.Worksheets("Sheet1")
lr1 = .Cells(.Rows.Count, "M").End(xlUp).Row
For r = lr1 To 2 Step -1
str = .Cells(r, "M").Value
If Application.WorksheetFunction.CountIf(rng, str) > 0 Then
Sheets("Sheet2").Range(Sheets("Sheet2").Cells(i, "A"), Sheets("Sheet2").Cells(i, "N")).Value = _
.Range(.Cells(r, "A"), .Cells(r, "N")).Value
.Range(.Cells(r, "A"), .Cells(r, "N")).Delete (xlShiftUp)
i = i + 1
End If
Next r
End With
Application.ScreenUpdating = True
End Sub
Yes, that's the way to go, but the lack of dots would have caused an error if that were the problem so there must be something else.
– SJR
Nov 12 '18 at 19:36
@SJR maybe there was a logical error with getting the last rows or something along those lines?
– Kubie
Nov 12 '18 at 19:39
Maybe so, think we're all rather in the dark until the OP clarifies.
– SJR
Nov 12 '18 at 19:44
Hello @Kubie Thank you for your help! The code is working fine, I can see multiple rows getting copied. But, the sheet "Sheet2" is getting overwritten every time. I want it to get appended with the new data. I tried adding an Offset, but that copied a single row. Any inputs?
– Siddharth
Nov 12 '18 at 21:28
1
@Siddharth use the find lastrow function for i that u also use for lr1
– Kubie
Nov 12 '18 at 23:00
|
show 6 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268511%2fvba-cut-paste-copies-only-one-row-and-not-all-the-rows%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Well here's your almost exact same code just added With
blocks and .
's because that might've been the problem
Sub DeleteRows()
Dim rng As Range
Dim r As Long
Dim lr1 As Long
Dim lr3 As Long
Dim str As Variant
Dim i As Long: i = 1
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("Sheet3")
lr3 = .Cells(.Rows.Count, "M").End(xlUp).Row
Set rng = .Range("M2:M" & lr3)
End With
With ThisWorkbook.Worksheets("Sheet1")
lr1 = .Cells(.Rows.Count, "M").End(xlUp).Row
For r = lr1 To 2 Step -1
str = .Cells(r, "M").Value
If Application.WorksheetFunction.CountIf(rng, str) > 0 Then
Sheets("Sheet2").Range(Sheets("Sheet2").Cells(i, "A"), Sheets("Sheet2").Cells(i, "N")).Value = _
.Range(.Cells(r, "A"), .Cells(r, "N")).Value
.Range(.Cells(r, "A"), .Cells(r, "N")).Delete (xlShiftUp)
i = i + 1
End If
Next r
End With
Application.ScreenUpdating = True
End Sub
Yes, that's the way to go, but the lack of dots would have caused an error if that were the problem so there must be something else.
– SJR
Nov 12 '18 at 19:36
@SJR maybe there was a logical error with getting the last rows or something along those lines?
– Kubie
Nov 12 '18 at 19:39
Maybe so, think we're all rather in the dark until the OP clarifies.
– SJR
Nov 12 '18 at 19:44
Hello @Kubie Thank you for your help! The code is working fine, I can see multiple rows getting copied. But, the sheet "Sheet2" is getting overwritten every time. I want it to get appended with the new data. I tried adding an Offset, but that copied a single row. Any inputs?
– Siddharth
Nov 12 '18 at 21:28
1
@Siddharth use the find lastrow function for i that u also use for lr1
– Kubie
Nov 12 '18 at 23:00
|
show 6 more comments
Well here's your almost exact same code just added With
blocks and .
's because that might've been the problem
Sub DeleteRows()
Dim rng As Range
Dim r As Long
Dim lr1 As Long
Dim lr3 As Long
Dim str As Variant
Dim i As Long: i = 1
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("Sheet3")
lr3 = .Cells(.Rows.Count, "M").End(xlUp).Row
Set rng = .Range("M2:M" & lr3)
End With
With ThisWorkbook.Worksheets("Sheet1")
lr1 = .Cells(.Rows.Count, "M").End(xlUp).Row
For r = lr1 To 2 Step -1
str = .Cells(r, "M").Value
If Application.WorksheetFunction.CountIf(rng, str) > 0 Then
Sheets("Sheet2").Range(Sheets("Sheet2").Cells(i, "A"), Sheets("Sheet2").Cells(i, "N")).Value = _
.Range(.Cells(r, "A"), .Cells(r, "N")).Value
.Range(.Cells(r, "A"), .Cells(r, "N")).Delete (xlShiftUp)
i = i + 1
End If
Next r
End With
Application.ScreenUpdating = True
End Sub
Yes, that's the way to go, but the lack of dots would have caused an error if that were the problem so there must be something else.
– SJR
Nov 12 '18 at 19:36
@SJR maybe there was a logical error with getting the last rows or something along those lines?
– Kubie
Nov 12 '18 at 19:39
Maybe so, think we're all rather in the dark until the OP clarifies.
– SJR
Nov 12 '18 at 19:44
Hello @Kubie Thank you for your help! The code is working fine, I can see multiple rows getting copied. But, the sheet "Sheet2" is getting overwritten every time. I want it to get appended with the new data. I tried adding an Offset, but that copied a single row. Any inputs?
– Siddharth
Nov 12 '18 at 21:28
1
@Siddharth use the find lastrow function for i that u also use for lr1
– Kubie
Nov 12 '18 at 23:00
|
show 6 more comments
Well here's your almost exact same code just added With
blocks and .
's because that might've been the problem
Sub DeleteRows()
Dim rng As Range
Dim r As Long
Dim lr1 As Long
Dim lr3 As Long
Dim str As Variant
Dim i As Long: i = 1
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("Sheet3")
lr3 = .Cells(.Rows.Count, "M").End(xlUp).Row
Set rng = .Range("M2:M" & lr3)
End With
With ThisWorkbook.Worksheets("Sheet1")
lr1 = .Cells(.Rows.Count, "M").End(xlUp).Row
For r = lr1 To 2 Step -1
str = .Cells(r, "M").Value
If Application.WorksheetFunction.CountIf(rng, str) > 0 Then
Sheets("Sheet2").Range(Sheets("Sheet2").Cells(i, "A"), Sheets("Sheet2").Cells(i, "N")).Value = _
.Range(.Cells(r, "A"), .Cells(r, "N")).Value
.Range(.Cells(r, "A"), .Cells(r, "N")).Delete (xlShiftUp)
i = i + 1
End If
Next r
End With
Application.ScreenUpdating = True
End Sub
Well here's your almost exact same code just added With
blocks and .
's because that might've been the problem
Sub DeleteRows()
Dim rng As Range
Dim r As Long
Dim lr1 As Long
Dim lr3 As Long
Dim str As Variant
Dim i As Long: i = 1
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("Sheet3")
lr3 = .Cells(.Rows.Count, "M").End(xlUp).Row
Set rng = .Range("M2:M" & lr3)
End With
With ThisWorkbook.Worksheets("Sheet1")
lr1 = .Cells(.Rows.Count, "M").End(xlUp).Row
For r = lr1 To 2 Step -1
str = .Cells(r, "M").Value
If Application.WorksheetFunction.CountIf(rng, str) > 0 Then
Sheets("Sheet2").Range(Sheets("Sheet2").Cells(i, "A"), Sheets("Sheet2").Cells(i, "N")).Value = _
.Range(.Cells(r, "A"), .Cells(r, "N")).Value
.Range(.Cells(r, "A"), .Cells(r, "N")).Delete (xlShiftUp)
i = i + 1
End If
Next r
End With
Application.ScreenUpdating = True
End Sub
edited Nov 12 '18 at 21:31
answered Nov 12 '18 at 19:21
KubieKubie
1,3521518
1,3521518
Yes, that's the way to go, but the lack of dots would have caused an error if that were the problem so there must be something else.
– SJR
Nov 12 '18 at 19:36
@SJR maybe there was a logical error with getting the last rows or something along those lines?
– Kubie
Nov 12 '18 at 19:39
Maybe so, think we're all rather in the dark until the OP clarifies.
– SJR
Nov 12 '18 at 19:44
Hello @Kubie Thank you for your help! The code is working fine, I can see multiple rows getting copied. But, the sheet "Sheet2" is getting overwritten every time. I want it to get appended with the new data. I tried adding an Offset, but that copied a single row. Any inputs?
– Siddharth
Nov 12 '18 at 21:28
1
@Siddharth use the find lastrow function for i that u also use for lr1
– Kubie
Nov 12 '18 at 23:00
|
show 6 more comments
Yes, that's the way to go, but the lack of dots would have caused an error if that were the problem so there must be something else.
– SJR
Nov 12 '18 at 19:36
@SJR maybe there was a logical error with getting the last rows or something along those lines?
– Kubie
Nov 12 '18 at 19:39
Maybe so, think we're all rather in the dark until the OP clarifies.
– SJR
Nov 12 '18 at 19:44
Hello @Kubie Thank you for your help! The code is working fine, I can see multiple rows getting copied. But, the sheet "Sheet2" is getting overwritten every time. I want it to get appended with the new data. I tried adding an Offset, but that copied a single row. Any inputs?
– Siddharth
Nov 12 '18 at 21:28
1
@Siddharth use the find lastrow function for i that u also use for lr1
– Kubie
Nov 12 '18 at 23:00
Yes, that's the way to go, but the lack of dots would have caused an error if that were the problem so there must be something else.
– SJR
Nov 12 '18 at 19:36
Yes, that's the way to go, but the lack of dots would have caused an error if that were the problem so there must be something else.
– SJR
Nov 12 '18 at 19:36
@SJR maybe there was a logical error with getting the last rows or something along those lines?
– Kubie
Nov 12 '18 at 19:39
@SJR maybe there was a logical error with getting the last rows or something along those lines?
– Kubie
Nov 12 '18 at 19:39
Maybe so, think we're all rather in the dark until the OP clarifies.
– SJR
Nov 12 '18 at 19:44
Maybe so, think we're all rather in the dark until the OP clarifies.
– SJR
Nov 12 '18 at 19:44
Hello @Kubie Thank you for your help! The code is working fine, I can see multiple rows getting copied. But, the sheet "Sheet2" is getting overwritten every time. I want it to get appended with the new data. I tried adding an Offset, but that copied a single row. Any inputs?
– Siddharth
Nov 12 '18 at 21:28
Hello @Kubie Thank you for your help! The code is working fine, I can see multiple rows getting copied. But, the sheet "Sheet2" is getting overwritten every time. I want it to get appended with the new data. I tried adding an Offset, but that copied a single row. Any inputs?
– Siddharth
Nov 12 '18 at 21:28
1
1
@Siddharth use the find lastrow function for i that u also use for lr1
– Kubie
Nov 12 '18 at 23:00
@Siddharth use the find lastrow function for i that u also use for lr1
– Kubie
Nov 12 '18 at 23:00
|
show 6 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268511%2fvba-cut-paste-copies-only-one-row-and-not-all-the-rows%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Bit hard to tell without seeing your data. Have you stepped through your code to see what's going on? You should add sheet references to all instances of
Cells
.– SJR
Nov 12 '18 at 19:07
If you're using
Cut
, why do you need aDelete
line?– dwirony
Nov 12 '18 at 19:08
@dwirony cut doesn't remove the line, it leaves an empty area
– Kubie
Nov 12 '18 at 19:10
@Kubie perhaps dwirony was implying keep the delete and drop the cut...
– Solar Mike
Nov 12 '18 at 19:14
@SolarMike good point, in that case can change the
cut
to arange.value = range.value
– Kubie
Nov 12 '18 at 19:16