Delete cells with VBA in Microsoft Excel

The following procedure is used to delete cell ranges from a selected worksheet:

Sub ZelleLoeschen()
Range("A2:A3").Delete Shift:=xlShiftUp
End Sub

The Delete () method of the Range object is called to delete cells. Here, too, there is an optional parameter Shift, with which you decide what should happen to the neighboring cells. If this parameter is omitted, Excel will again decide on the basis of the area shape. In the first case, entire lines are selected. There can only be one shift (all lines below) upwards, so specifying the Shift parameter does not make any sense. In the second case, the lower neighboring cells are shifted upwards. The constant xlShiftUp is used for this. The constant xlShiftToLeft would have shifted the right neighbor cells to the left.

The instruction Range ("A2: A3"). EntireRow.Delete would delete the entire lines of the specified range, in this case lines 2 and 3. Correspondingly, the instruction Range ("A2: A3"). EntireColumn. Delete the entire column A is deleted.

Was the explanation to "Delete cells with VBA in Microsoft Excel"Helpful? Rate now:

Weitere Erklärungen zu Skriptsprachen