Hi Excel solvers. Please help me as I would like the macro to figure if there is any blank rows or columns and delete them. How could I write this in macro? Thank you.
Delete blank rows and columns in Excel through macros
-
M1991 -
May 25, 2021 at 10:52 PM -
Thread is marked as Resolved.
-
-
-
Hello M1991,
You had best attach a sample workbook showing us exactly what you are trying to do. Please give us a precise description.
Cheerio,
vcoolio.
-
Hi M1,
You can try this:
Code
Display MoreSub delblankRC() Application.ScreenUpdating = False Dim ws1 As Worksheet: Set ws1 = Sheet1 Dim x As Long, y As Long, myR As Long, myC As Long x = ws1.UsedRange.Rows.Count y = ws1.UsedRange.Columns.Count For myR = x To 1 Step -1 If Application.CountA(ws1.Cells(myR, 1).EntireRow) = 0 Then ws1.Cells(myR, 1).EntireRow.Delete Next myR For myC = y To 1 Step -1 If Application.CountA(ws1.Cells(1, myC).EntireColumn) = 0 Then ws1.Cells(1, myC).EntireColumn.Delete Next myC Application.ScreenUpdating = True End Sub
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!