View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
royUK[_141_] royUK[_141_] is offline
external usenet poster
 
Posts: 1
Default Deleting blank columns


I agree with Simon.

1)Code to delete Rows should start from the end of the data and work
backwards
2)Looping to remove rows is the most inefficient way to do this
action.
2)Your code will Loop 2000 times, and it uses two variables where one
is all that is needed.

You could use AutoFilter to filter for blanks then delete the resulting
filtered range -no VBA necessary.

I would slightly amend Simon's code to just check only the UsedRange



VBA Code:
--------------------


Sub remove_rows_if_a_is_blank()
With Sheet1.UsedRange '<-change the sheet as required
.Columns(1).SpecialCells(xlCellTypeBlanks).EntireR ow.Delete
End With
End Sub
--------------------


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?u=15
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=207689

http://www.thecodecage.com/forumz


--- news://freenews.netfront.net/ - complaints: ---