Hello Everyone!
I have a code here(please find below) and was wondering if you could help out.
I am using this code to delete all the blank rows in a worksheet , and this code works fine.
The problem I am Having is that, when I run the code it only does it for the current worksheet I am on. I have around 13 worksheets and was wondering if it could be applied to all the active worksheets when I run the macro once, without having to run the macro for each worksheet.
Any help is much appreciated! Thank you in advance!
Public Sub DeleteRowFINAL()
Application.ScreenUpdating = False
For Each usedrng In ActiveSheet.UsedRange
If usedrng.MergeCells = True Then
If usedrng.Value = "" Then
usedrng.Value = ""
End If
Else
If usedrng.Value = "" Then
usedrng.ClearContents
End If
End If
Next
ActiveSheet.UsedRange
usedRangeLastColNum = ActiveSheet.UsedRange.Columns.<wbr>Count
usedrangelastrow = ActiveSheet.UsedRange.Rows.<wbr>Count
For r = usedrangelastrow To 1 Step -1
If Application.WorksheetFunction.<wbr>CountA(Cells(r, usedRangeLastColNum).<wbr>EntireRow) <> 0 Then
Exit For
Else
Cells(r, usedRangeLastColNum).<wbr>EntireRow.Delete
End If
Next r
For c = usedRangeLastColNum To 1 Step -1
If Application.WorksheetFunction.<wbr>CountA(Cells(1, c).EntireColumn) <> 0 Then
Exit For
Else
Cells(1, c).EntireColumn.Delete
End If
Next c
ActiveSheet.UsedRange
Application.ScreenUpdating = True
Dim rgCol As Range
On Error Resume Next
For Each rgCol In Range("A2:G102").Columns
rgCol.SpecialCells(<wbr>xlCellTypeBlanks).EntireRow.<wbr>Delete
Next rgCol
End Sub
I have a code here(please find below) and was wondering if you could help out.
I am using this code to delete all the blank rows in a worksheet , and this code works fine.
The problem I am Having is that, when I run the code it only does it for the current worksheet I am on. I have around 13 worksheets and was wondering if it could be applied to all the active worksheets when I run the macro once, without having to run the macro for each worksheet.
Any help is much appreciated! Thank you in advance!
Public Sub DeleteRowFINAL()
Application.ScreenUpdating = False
For Each usedrng In ActiveSheet.UsedRange
If usedrng.MergeCells = True Then
If usedrng.Value = "" Then
usedrng.Value = ""
End If
Else
If usedrng.Value = "" Then
usedrng.ClearContents
End If
End If
Next
ActiveSheet.UsedRange
usedRangeLastColNum = ActiveSheet.UsedRange.Columns.<wbr>Count
usedrangelastrow = ActiveSheet.UsedRange.Rows.<wbr>Count
For r = usedrangelastrow To 1 Step -1
If Application.WorksheetFunction.<wbr>CountA(Cells(r, usedRangeLastColNum).<wbr>EntireRow) <> 0 Then
Exit For
Else
Cells(r, usedRangeLastColNum).<wbr>EntireRow.Delete
End If
Next r
For c = usedRangeLastColNum To 1 Step -1
If Application.WorksheetFunction.<wbr>CountA(Cells(1, c).EntireColumn) <> 0 Then
Exit For
Else
Cells(1, c).EntireColumn.Delete
End If
Next c
ActiveSheet.UsedRange
Application.ScreenUpdating = True
Dim rgCol As Range
On Error Resume Next
For Each rgCol In Range("A2:G102").Columns
rgCol.SpecialCells(<wbr>xlCellTypeBlanks).EntireRow.<wbr>Delete
Next rgCol
End Sub