PDA

View Full Version : [SOLVED] Empty Row Deletion



Onibaku_Rave
05-27-2016, 11:05 AM
Hi All,

My goal is to create a macro that deletes entire rows that contain no data, save for the first column which is the task name. Depending on which month I need to pull the data from, the number of days in the month will change and the number of tasks will also change, so those will have to be dynamic. I also want the macro to ignore the last two rows, which contains a spacer row and a set of numbers irrelevant to the data. The code that I have would delete rows, but it is for a static data set and won't work if I need to pull a different month.

16279

Paul_Hossler
05-27-2016, 12:39 PM
You can start with this




Option Explicit
Sub DeleteEmptyRow()
Dim iLastRowNum As Long, iRowNum As Long

Application.ScreenUpdating = False

With ActiveSheet
iLastRowNum = .Cells(.Rows.Count, 1).End(xlUp).Row

For iRowNum = iLastRowNum To 2 Step -1
If Application.WorksheetFunction.CountA(.Rows(iRowNum)) = 1 Then
.Rows(iRowNum).Delete
End If
Next
End With
Application.ScreenUpdating = True
End Sub

Onibaku_Rave
05-27-2016, 01:04 PM
You can start with this




Option Explicit
Sub DeleteEmptyRow()
Dim iLastRowNum As Long, iRowNum As Long

Application.ScreenUpdating = False

With ActiveSheet
iLastRowNum = .Cells(.Rows.Count, 1).End(xlUp).Row

For iRowNum = iLastRowNum To 2 Step -1
If Application.WorksheetFunction.CountA(.Rows(iRowNum)) = 1 Then
.Rows(iRowNum).Delete
End If
Next
End With
Application.ScreenUpdating = True
End Sub



Thanks Paul, I think this should be enough to work with!