Remove columns with all zeros
Hello. I set up teh macro and it removed teh columns with all zeros. It also
removed columns containing text data. How can I tweak the macro below so it
ignores columns that contain data such as names, job title, etc.
Thanks again for your asisstance.
"Gary''s Student" wrote:
Try this:
Sub RemoveColumns()
Dim nLastColumn As Long
Set r = ActiveSheet.UsedRange
nLastColumn = r.Columns.Count + r.Column - 1
For i = nLastColumn To 1 Step -1
If Application.WorksheetFunction.Sum(Columns(i)) = 0 Then
Columns(i).Delete
End If
Next
End Sub
--
Gary''s Student - gsnu201003
"Nora_GG" wrote:
How can I remove columns that contain all zeros? Is there a macro? I craeted
a sumif formula to flag columns subtotaling zero but I need a method to
remove these columns. Thanks
|