Hi Everyone,
I would like to ask for some help writing a few lines of codes to speed up the generation of a few reports. I would like to have the code delete a column if the column only contains text.
So far I have the following code I have created through a bit of research online
Thank you
I would like to ask for some help writing a few lines of codes to speed up the generation of a few reports. I would like to have the code delete a column if the column only contains text.
So far I have the following code I have created through a bit of research online
Code:
Dim addcell As Range
Dim lrow As Long, lcol As Long
Dim WorkRng As Range
lrow = Cells(Rows.Count, 1).End(xlUp).Row
lcol = Cells(1, Columns.Count).End(xlToLeft).Column
Range("A1").End(xlDown).Offset(1).EntireRow.NumberFormat = "General"
Range("A1").End(xlDown).Offset(, 32).Select
Set addcell = ActiveCell
Range("A1").End(xlDown).Offset(1, 32).Formula = "=COUNT(CR[-1]:addcell)"
Range("A1").End(xlDown).Offset(1, 32).Copy
Range(Range("A1").End(xlDown).Offset(1, 32), Cells(lrow + 1, lcol)).PasteSpecial xlPasteFormulas
Range(Range("A1").End(xlDown).Offset(1, 32), Cells(lrow + 1, lcol)).Copy
Range(Range("A1").End(xlDown).Offset(1, 32), Cells(lrow + 1, lcol)).PasteSpecial xlPasteValuesAndNumberFormats
Range("A1").End(xlDown).Offset(1).Delete Shift:=xlToLeft
Set WorkRng = Range(Cells(lrow + 1, 31), Cells(lrow + 1, lcol))
For Each cell In WorkRng
If cell.Value < 0 Then cell.EntireColumn.Delete
Next
End Sub
Thank you