ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range.Delete Shift causing merged cells to unmerge (https://www.excelbanter.com/excel-programming/418440-range-delete-shift-causing-merged-cells-unmerge.html)

MichaelDavid

Range.Delete Shift causing merged cells to unmerge
 
Greetings! In over 300 executions, the following code never failed nor
displayed a message:

' The follwg instructions will delete the first 28 rows:

Application.Goto Reference:="R1:R28"
Selection.Delete Shift:=xlUp

But when I revised the code as follows (hoping for greater speed):

Range("R1:R28").Delete Shift:=xlUp

two out of three executions caused the following message to display: "This
Operation will cause some merged cells to unmerge; Do you wish to continue?"

The two sets of code seem to provide the same function. What could be wrong
with "Range("R1:R28").Delete Shift:=xlUp"? Thanks in advance for your help.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick

MichaelDavid

Range.Delete Shift causing merged cells to unmerge
 
Greetings! I forgot to add that after I got the two out of three "failures"
with the revised code, I then executed the original code on the same data
with no problems.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick


"MichaelDavid" wrote:

Greetings! In over 300 executions, the following code never failed nor
displayed a message:

' The follwg instructions will delete the first 28 rows:

Application.Goto Reference:="R1:R28"
Selection.Delete Shift:=xlUp

But when I revised the code as follows (hoping for greater speed):

Range("R1:R28").Delete Shift:=xlUp

two out of three executions caused the following message to display: "This
Operation will cause some merged cells to unmerge; Do you wish to continue?"

The two sets of code seem to provide the same function. What could be wrong
with "Range("R1:R28").Delete Shift:=xlUp"? Thanks in advance for your help.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick


Per Jessen[_2_]

Range.Delete Shift causing merged cells to unmerge
 
Hi Michael

It seems that


* * * *Application.Goto Reference:="R1:R28"


is selecting entire rows 1:28 not only column R row 1:28, thus merged
cells is selected and will be deleted at once.

* * * *Selection.Delete Shift:=xlUp

But when I revised the code as follows (hoping for greater speed):

* * * Range("R1:R28").Delete Shift:=xlUp

The code above is only deleting the stated range, thus cells in the
range merged with cells in other columns will cause the error!

Hopes that helps

Regards,
Per




MichaelDavid

Range.Delete Shift causing merged cells to unmerge
 
Greetings! Thanks for your help. What then would be the quickest way of
deleting entire rows 1 through 28? Thanks in advance.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick


"Per Jessen" wrote:

Hi Michael

It seems that


Application.Goto Reference:="R1:R28"


is selecting entire rows 1:28 not only column R row 1:28, thus merged
cells is selected and will be deleted at once.

Selection.Delete Shift:=xlUp

But when I revised the code as follows (hoping for greater speed):

Range("R1:R28").Delete Shift:=xlUp

The code above is only deleting the stated range, thus cells in the
range merged with cells in other columns will cause the error!

Hopes that helps

Regards,
Per





MichaelDavid

Range.Delete Shift causing merged cells to unmerge
 
Greetings! I browsed around in Google, and saw a possible solution. Perhaps
something like

Range("R1:R28").EntireRow.Delete Shift:=xlUp might work. This statement does
compile without error. I will try to execute it later on today.

--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick


"Per Jessen" wrote:

Hi Michael

It seems that


Application.Goto Reference:="R1:R28"


is selecting entire rows 1:28 not only column R row 1:28, thus merged
cells is selected and will be deleted at once.

Selection.Delete Shift:=xlUp

But when I revised the code as follows (hoping for greater speed):

Range("R1:R28").Delete Shift:=xlUp

The code above is only deleting the stated range, thus cells in the
range merged with cells in other columns will cause the error!

Hopes that helps

Regards,
Per






All times are GMT +1. The time now is 02:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com