Delete entire row in a user defined range if cell is blank using VBA in Excel

preview_player
Показать описание
This video explains the coding behind my Delete rows that is available in the AddIn.
The code:
Sub deleteRows()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

On Error GoTo err
If InputBox("Do you Have backup of the file?? You can not UNDO once you run this Program. Type YES or NO.") = "yes" Then

Dim n, s As Long
n = InputBox("insert row number")
s = InputBox("insert column number")
Range(Cells(n, s), Cells(Rows.Count, s).End(xlUp)).Select

For n = Selection.Rows.Count To 5 Step -1

If WorksheetFunction.CountA(Cells(n, s).EntireRow) = 0 Then
Cells(n, s).EntireRow.Delete
End If
Next n
GoTo complete
Else
GoTo En
End If

err:
MsgBox ("Error? see Syed")
GoTo En
complete:
MsgBox ("Completed")
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

En:
End Sub
Рекомендации по теме
Комментарии
Автор

With Range("F2:F500")
    .Replace "delivered", ""
   
    
End With

Ryzwa
Автор

thanks for the info, i have a question. If data from row A is blank, but row B, C, etc has data, but i still needed to delete entire row as long as row A is blank. can you advise on how to change your VBA to allow deletion of the entire column.

mariomalek
Автор

Hi Syed, this is great, however is there a way to make your code built into a series of codes automatically and not manually as you've shown above.

For example, when I copy data from sheet 1 to sheet 2, I would like to use your code to clean up the sheet 2 from any blank rows before auto saving the file.


What I mean is I have a VBA code to transfer the data from sheet 1 to sheet 2 and I would like to append your code to the existing code without the need of user input.

What do you think?

iainbayly
visit shbcf.ru