Selection.Delete Shift:=xlUp

terry87

New Member
Joined
Sep 22, 2015
Messages
9
I want to delete contents of some cells and then shift the cells up without modifying formulae in the same rows of the deleted cells.

Currently when I delete the cells and move the cells up to replace the deleted cells, any formulae in the rows of the deleted cells are modifed and reference cells incorrectly. I know I can delete the rows to get the desired result but I am doing many similar deletions which would mean I would have to copy the formulae again many many times.

Any ideas
terry87
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,203
Office Version
  1. 365
Platform
  1. Windows
Rather than delete the rows, why not clear the contents & then sort.
 
Last edited:

terry87

New Member
Joined
Sep 22, 2015
Messages
9
Sorting would not help as I need the remaining cells in the same order as they were before.

:(
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,203
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Sorting would not help as I need the remaining cells in the same order as they were before.

:(
Not a problem, you can add a helper column with the values 1,2,3 etc & then sort on that. That way your data remains in the same order but without the blank rows.
 

terry87

New Member
Joined
Sep 22, 2015
Messages
9

ADVERTISEMENT

Can you please expand on your suggestion....

I guess another solution would be to create a macro which selects the columns with the incorrect reference "#Ref!" and replace with correct reference "A1"
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,203
Office Version
  1. 365
Platform
  1. Windows
If you had data like this, with the helper col H

<b>Excel 2013 32 bit</b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255, 255, 255);border: 1px solid;border-collapse: collapse; border-color: rgb(182, 170, 166)"><colgroup><col width="25px" style="background-color: rgb(240, 224, 224)" /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(240, 224, 224);text-align: center;color: rgb(32, 17, 22)"><th></th><th>A</th><th>B</th><th>G</th><th>H</th></tr></thead><tbody><tr ><td style="color: rgb(32, 17, 22);text-align: center;">1</td><td style=";">Postcode</td><td style=";">In Use?</td><td style=";">GridRef</td><td style=";">Helper</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">2</td><td style=";">AL1 5EG</td><td style=";">Yes</td><td style=";">TL159070</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">3</td><td style=";">AL10 9WX</td><td style=";">Yes</td><td style=";">TL219072</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">4</td><td style=";">AL2 1UX</td><td style=";">Yes</td><td style=";">TL166039</td><td style="text-align: right;;">3</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">5</td><td style=";">AL2 2EJ</td><td style=";">Yes</td><td style=";">TL157017</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">6</td><td style=";">AL2 2EX</td><td style=";">Yes</td><td style=";">TL154047</td><td style="text-align: right;;">5</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">7</td><td style=";">AL2 3XZ</td><td style=";">Yes</td><td style=";">TL129021</td><td style="text-align: right;;">6</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">8</td><td style=";">AL2 3YT</td><td style=";">Yes</td><td style=";">TL126016</td><td style="text-align: right;;">7</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">9</td><td style=";">AL3 6AD</td><td style=";">Yes</td><td style=";">TL132069</td><td style="text-align: right;;">8</td></tr></tbody></table><p style="width:10.2em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(182, 170, 166);border-top:none;text-align: center;background-color: rgb(240, 224, 224);color: rgb(32, 17, 22)">England postcodes</p><br /><br />

After clearing some rows you get

<b>Excel 2013 32 bit</b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255, 255, 255);border: 1px solid;border-collapse: collapse; border-color: rgb(182, 170, 166)"><colgroup><col width="25px" style="background-color: rgb(240, 224, 224)" /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(240, 224, 224);text-align: center;color: rgb(32, 17, 22)"><th></th><th>A</th><th>B</th><th>G</th><th>H</th></tr></thead><tbody><tr ><td style="color: rgb(32, 17, 22);text-align: center;">1</td><td style=";">Postcode</td><td style=";">In Use?</td><td style=";">GridRef</td><td style=";">Helper</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">2</td><td style=";">AL1 5EG</td><td style=";">Yes</td><td style=";">TL159070</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">3</td><td style=";">AL10 9WX</td><td style=";">Yes</td><td style=";">TL219072</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">5</td><td style=";">AL2 2EJ</td><td style=";">Yes</td><td style=";">TL157017</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">6</td><td style=";">AL2 2EX</td><td style=";">Yes</td><td style=";">TL154047</td><td style="text-align: right;;">5</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">7</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">8</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">9</td><td style=";">AL3 6AD</td><td style=";">Yes</td><td style=";">TL132069</td><td style="text-align: right;;">8</td></tr></tbody></table><p style="width:10.2em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(182, 170, 166);border-top:none;text-align: center;background-color: rgb(240, 224, 224);color: rgb(32, 17, 22)">England postcodes</p><br /><br />

And then sort

<b>Excel 2013 32 bit</b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255, 255, 255);border: 1px solid;border-collapse: collapse; border-color: rgb(182, 170, 166)"><colgroup><col width="25px" style="background-color: rgb(240, 224, 224)" /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(240, 224, 224);text-align: center;color: rgb(32, 17, 22)"><th></th><th>A</th><th>B</th><th>G</th><th>H</th></tr></thead><tbody><tr ><td style="color: rgb(32, 17, 22);text-align: center;">1</td><td style=";">Postcode</td><td style=";">In Use?</td><td style=";">GridRef</td><td style=";">Helper</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">2</td><td style=";">AL1 5EG</td><td style=";">Yes</td><td style=";">TL159070</td><td style="text-align: right;;">1</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">3</td><td style=";">AL10 9WX</td><td style=";">Yes</td><td style=";">TL219072</td><td style="text-align: right;;">2</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">4</td><td style=";">AL2 2EJ</td><td style=";">Yes</td><td style=";">TL157017</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">5</td><td style=";">AL2 2EX</td><td style=";">Yes</td><td style=";">TL154047</td><td style="text-align: right;;">5</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">6</td><td style=";">AL3 6AD</td><td style=";">Yes</td><td style=";">TL132069</td><td style="text-align: right;;">8</td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">7</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">8</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(32, 17, 22);text-align: center;">9</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:10.2em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(182, 170, 166);border-top:none;text-align: center;background-color: rgb(240, 224, 224);color: rgb(32, 17, 22)">England postcodes</p><br /><br />
 

terry87

New Member
Joined
Sep 22, 2015
Messages
9
:)
Fluff that is brilliant. I have spent days on this. Thank you so much

Terry97
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,203
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,123,143
Messages
5,599,975
Members
414,354
Latest member
Flaxarn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top