View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Loop through column(s) to check values, perform action based on ch

Sub checkcolumns()
Dim rng as Range, r as Range, cell as range
set rng = Range("A1:Z1")
for each cell in rng
set r = Range(cell,Cells(rows.count,cell.column).End(xlup) )
if application.countif(r,cell) = Application.CountA(r) then
cell.EntireColumn.Hidden = True
else
cell.EntireColumn.Hidden = False
end if
Next
End Sub

Assumes the first row will contain values.

--
regards,
Tom Ogilvy


"ward376" wrote:

I hope someone has something like this worked out - How to loop
through a column and if every cell contains a certain value (i.e.all
zeros), hide or delete the column.

Thanks!
ward376