Timely insight needed.
Have a worksheet with 2013 and 2014 in cells C3 and F3, respectively and additional data from cells A4 through H16.
Column headers are in row 4 with columns D and E containing column headers but no data below column headers.
Objective is to create a macro to delete all columns within the used range that have column headers but no data in the column
below the column headers. Note, this will be a recurring daily task.
Any insight as to the modifications needed in the code below to accomplish objective is appreciated.
Have a worksheet with 2013 and 2014 in cells C3 and F3, respectively and additional data from cells A4 through H16.
Column headers are in row 4 with columns D and E containing column headers but no data below column headers.
Objective is to create a macro to delete all columns within the used range that have column headers but no data in the column
below the column headers. Note, this will be a recurring daily task.
Any insight as to the modifications needed in the code below to accomplish objective is appreciated.
Code:
Set inputrng = Application.Worksheets("DataCopy").UsedRange
Application.ScreenUpdating = False
For i = inputrng.Columns.Count To 1 Step -1
Set rngDataCopy = inputrng.Cells(4, i).EntireColumn
If Application.WorksheetFunction.CountA(rngDataCopy) = 0 Then
rngDataCopy.Delete
End If
Next
Application.ScreenUpdating = True