sidewayze40
Technical User
Thank you in advance for any help on this... I have built a benchmarking program in access... once the user makes their selection of the items to compare, the program will output an excel file. The file has column headers for each possibility on the form and thus has lots of empty columns. I am looking for a way to have this code ran on the excel file immediately after the output.
Sub DeleteEmptyRowsAndColumns()
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
LastColumn = ActiveSheet.UsedRange.Column - 1 + _
ActiveSheet.UsedRange.Columns.Count
Application.ScreenUpdating = False
For c = LastColumn To 1 Step -1
If Application.CountA(Columns(c)) = 1 Then Columns(c).Delete
Next c
End Sub
Is this possible?
Sub DeleteEmptyRowsAndColumns()
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
LastColumn = ActiveSheet.UsedRange.Column - 1 + _
ActiveSheet.UsedRange.Columns.Count
Application.ScreenUpdating = False
For c = LastColumn To 1 Step -1
If Application.CountA(Columns(c)) = 1 Then Columns(c).Delete
Next c
End Sub
Is this possible?