If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How can I update macro to delete zero amount columns?
I have a spreadsheet that contains columns with text (such as name, job
title, hire date, etc.) and several columns with amounts. I want to delete the "amount" columns that contain all zeros. I used the macro below and it removed all the amount columns that contained just zeros but it also removed the columns that contained the name, title, etc. How can I change the macro below to remove only the zero amount columns and leave the other text columns? Thanks for the assistance. 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 |
Thread Tools | |
Display Modes | |
|
|