Home > Software engineering >  Excel VBA causing an err 0 when deleting a row
Excel VBA causing an err 0 when deleting a row

Time:03-04

I have tried a number of different ways to delete a row in my Excel 2016 but I keep getting and err.number 0!

    ' Remove Extra Top Row
Rows(1).EntireRow.Delete Shift:=xlUp 'The created rows have an extra blank line. This removes it and shifts the rest up

Err_FilterCSV:
MsgBox Err.Description, vbCritical, Err.Number

This throws an err 0 every time.

I even tried this

    ActiveSheet.Range("C1:E1").Select 'The created rows have an extra blank line. This removes it and shifts the rest up
Selection.Delete Shift:=xlUp

And it still gives an err 0

CodePudding user response:

Just use Rows(1).EntireRow.Delete without additional param

CodePudding user response:

I believe your error is with the .delete method shift parameter. xlShiftUp needs to be used.

Rows(1).Delete xlShiftUp

Using the Rows property without an object qualifier is equivalent to using ActiveSheet.Rows. For more information, see the Worksheet.Rows property.

Check these pages for more information on the delete method and rows property for a range object.

  • Related