Guna13
Board Regular
- Joined
- Nov 22, 2019
- Messages
- 70
- Office Version
- 365
- Platform
- Windows
Hi All,
I need assistance on how to efficiently delete blank and empty columns based on a condition in the second row, starting from "F" column to the last column. I have updated the entire project code information in columns F1 to the last column, totaling more than 150+ columns. In the second row, if a project is used, it will have a corresponding number proportion like 1 or 0.50, 0.30, etc., but the sum of these values should not exceed 1 (100%).
Can someone please guide me on how to find and delete the empty columns that do not meet this condition? this below code is running. but just taking time. ( because this is repeated process for more than 6000+ Employee. so my performance is down.
Thank you for your help.
Emample screen shot.
I need assistance on how to efficiently delete blank and empty columns based on a condition in the second row, starting from "F" column to the last column. I have updated the entire project code information in columns F1 to the last column, totaling more than 150+ columns. In the second row, if a project is used, it will have a corresponding number proportion like 1 or 0.50, 0.30, etc., but the sum of these values should not exceed 1 (100%).
Can someone please guide me on how to find and delete the empty columns that do not meet this condition? this below code is running. but just taking time. ( because this is repeated process for more than 6000+ Employee. so my performance is down.
Thank you for your help.
VBA Code:
Sub DeleteEmptyProjectColumns_New()
Dim ws As Worksheet
Dim rng As Range
Dim col As Range
Dim lastColumn As Long
Set ws = ThisWorkbook.Sheets("WS")
lastColumn = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
Set rng = ws.Range(ws.Cells(1, 6), ws.Cells(1, lastColumn))
For i = lastColumn To 6 Step -1
If ws.Cells(2, i).Value = "" Or Not IsNumeric(ws.Cells(2, i).Value) Then
ws.Columns(i).Delete
End If
Next i
End Sub
Emample screen shot.