View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Code to delete columns meeting a condition

You need an End If

Sub DeleteColumnsGreaterThanH1()
Range("be2").Select
Do While Selection.Column 8
If ActiveCell.Value Range("h1").Value Then
Selection.EntireColumn.Delete
ActiveCell.Offset(0, -1).Select
End If
Loop
End Sub


Gord Dibben MS Excel MVP

On Fri, 2 Feb 2007 14:51:01 -0800, CEG wrote:

I got a "Loop without Do" error.