Hi All:
I have been using the following code (see below) that I got from a Board Member (THANKS) to Delete Blank Rows in my Worksheet. It also pops up a message to give the User one last chance to terminate the Delete. It works excellently...
My problem is that I now have added data to the Right of my Ranges that will always be populated.
QUESTION: I was wondering if anyone knows how to tweak this code so that it checks the row but only within the named Range (e.g. one Range is titled "AR") OR if it can check the rows but only up to column J. So this would mean that if columns A to J are Blank then delete that row.
I am not very knowledgeable in VBA but I am pretty sure that this is the line that needs changing:
If Application.WorksheetFunction.CountA(rng.Rows(R).EntireRow) = 0 Then
rng.Rows(R).EntireRow.Delete
I am not sure how to go about it...
HERE IS THE ORIGINAL CODE:
THANKS to anyone that can help.
Bye 4 Now,
Mark
I have been using the following code (see below) that I got from a Board Member (THANKS) to Delete Blank Rows in my Worksheet. It also pops up a message to give the User one last chance to terminate the Delete. It works excellently...
My problem is that I now have added data to the Right of my Ranges that will always be populated.
QUESTION: I was wondering if anyone knows how to tweak this code so that it checks the row but only within the named Range (e.g. one Range is titled "AR") OR if it can check the rows but only up to column J. So this would mean that if columns A to J are Blank then delete that row.
I am not very knowledgeable in VBA but I am pretty sure that this is the line that needs changing:
If Application.WorksheetFunction.CountA(rng.Rows(R).EntireRow) = 0 Then
rng.Rows(R).EntireRow.Delete
I am not sure how to go about it...
HERE IS THE ORIGINAL CODE:
Code:
Sub DeleteARBlankRows()
' (FINAL)
ActiveSheet.Unprotect
Answer = MsgBox("WARNING! Do you really want to Delete the Blank Rows?" & vbCr & vbCr & "PLEASE DO NOT DELETE the Blank Rows if you have not entered any data into this section as it may render the sheet unusable." & vbCr & vbCr & "If you are not using this section PLEASE click the HIDE buttion instead." & vbCr & vbCr & "If you still want to DELETE these lines than CLICK OK otherwise Click Cancel.", vbOKCancel, "WARNING!")
If Answer = vbCancel Then Exit Sub
Dim R As Long
Dim rng As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set rng = Range("AR")
For R = rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(rng.Rows(R).EntireRow) = 0 Then
rng.Rows(R).EntireRow.Delete
End If
Next R
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
THANKS to anyone that can help.
Bye 4 Now,
Mark