Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete cells without shifting them up

I have vba macro to delete a selection of cells. Its shifting the cells up automatically after deleting them. I don't want the cells to be shifted up, as I have a chart below the cells and everything gets disturbed if they are shifted.

Here is the code I am using to delete cells

ActiveSheet.UsedRange.Select
ActiveSheet.Range("C2:H8").Select
Selection.Delete

Let me know how can I delete them without shifting up.

like image 224
Jill448 Avatar asked Oct 25 '25 00:10

Jill448


1 Answers

You could use

ActiveSheet.Range("C2:H8").ClearContents 

that'll empty the content without shifting anything.

like image 145
P. O. Avatar answered Oct 26 '25 17:10

P. O.