View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Auto Delete Columns in a Macro that are Blank

Option Explicit
Sub Testme()

dim iCol as long
dim Wks as worksheet

set wks = worksheets("somenamehere")

with wks
for icol = .usedrange.columns(.usedrange.columns.count).colum n _
to 1 step -1
if application.counta(.columns(icol)) 0 then
'there's something in that column, skip it
else
.columns(icol).delete
end if
next icol
end with

end sub

dkeglor wrote:

Hello! I have a very large spreadsheet that I have created a Macro to format
and formulate. I can't seem to find the correct coding to put into the macro
to search each and every column and get it to auto delete the column if it is
blank (contains no data). Can someone help me with this?


--

Dave Peterson