I'm new here and have been racking my brain for about a week to try and figure this out. I have also searched everywhere and every example I try to fix my issue doesn't work. So, I apologize if this is somewhere on here but couldn't find it.
My delema, I have a computer generated spreadsheet that creates over 2000 lines in Excel. Half are empty blank rows. My goal is to delete all of the empty rows then insert a rows before, if column "n" has a value of Y or N.
I have the delete the blank rows figured out but am struggling on adding the rows based on the value. Any help would be appreciated.
Sub DeleteBlankRows()
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
xRows = WorkRng.Rows.Count
Application.ScreenUpdating = False
For i = xRows To 1 Step -1
If Application.WorksheetFunction.CountA(WorkRng.Rows(i)) = 0 Then
WorkRng.Rows(i).EntireRow.Delete XlDeleteShiftDirection.xlShiftUp
End If
Next
Application.ScreenUpdating = True
End Sub
Sub InsertRow()
If ActiveCell = "y" Then
Selection.EntireRow.Insert
If ActiveCell = "n" Then
Selection.EntireRow.Insert
End If
End If
End Sub