Hello,
I have a problem with my VBA code, it takes a lot of time to execute even if the code seems quite simple...
For the context, I have a very large sheet with a pattern of 3 columns (Month, Year and Value) and I want to delete the three of them if the value cell is empty. It has around 1000 columns and 2000 rows. The code works but takes ages, and after a while Excel freezes and stops working
Here is my current code :
Thank you for reading me !
Coralie (I'm french, sorry for my English
)
I have a problem with my VBA code, it takes a lot of time to execute even if the code seems quite simple...

For the context, I have a very large sheet with a pattern of 3 columns (Month, Year and Value) and I want to delete the three of them if the value cell is empty. It has around 1000 columns and 2000 rows. The code works but takes ages, and after a while Excel freezes and stops working

Here is my current code :
Code:
Sub del_empty()
Dim NbCol, i As Long
Dim NbRow, j As Long
NbCol = Cells(1, Rows(1).Cells.Count).End(xlToLeft).Column
For i = NbCol To 1 Step -3
NbRow = Cells(Rows.Count, i).End(xlUp).Row
For j = NbRow - 1 To 2 Step -1
If Cells(j + 1, i) = "" Then
Cells(j + 1, i - 2).Delete
Cells(j + 1, i - 1).Delete
Cells(j + 1, i).Delete
End If
Next
Next
End Sub
Thank you for reading me !

Coralie (I'm french, sorry for my English
