Pquigrafamos
New Member
- Joined
- Sep 8, 2021
- Messages
- 18
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hello! At a certain point of a bigger macro, I have the need to eliminate all columns that have no filled cells, in the range A to H.
The following piece of code does it perfectly, but it makes the whole macro extremely slow (More than 2 minutes waiting):
Can you please advise if I am doing something wrong here, if there is a way of optimizing this step?
Best regards!!
The following piece of code does it perfectly, but it makes the whole macro extremely slow (More than 2 minutes waiting):
VBA Code:
sub El_col1()
Worksheets("Tables").Activate
Dim Filled_cells As Integer
Dim x As Integer
For x = 1 To 8
Filled_cells = Application.WorksheetFunction.CountA(Columns(x))
If Filled_cells = 0 Then
Columns(x).EntireColumn.Delete
End If
Next
End sub
Can you please advise if I am doing something wrong here, if there is a way of optimizing this step?
Best regards!!