Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You can try this:
Sub DelCol() Dim iColCount As Integer Dim varVal As Variant Range("A1").Select varVal = ActiveCell.Value Do Until iColCount = 256 varVal = ActiveCell.Value If varVal = "No BU" Then Selection.EntireColumn.Delete If ActiveCell.Column < 256 Then ActiveCell.Offset(0, 1).Select iColCount = iColCount + 1 Loop -- Kevin Backmann "GarToms" wrote: I use this macro code to delete columns in a table that are headed 'No BU'. Currently I press it until all the 'No BU' columns are deleted. Once all the columns have been deleted it displays a 91 error. Does anyone know how to edit this macro code to loop it (so i dont have to repress the button), and finish the macro when there are no more 'No BU' columns to delete (without the error). Sub DeleteColumns() ' ' DeleteColumns Macro ' Macro recorded 27/01/2006 by Corus ' ' Cells.Find(What:="No BU", After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False).Activate Range(Selection, Selection.End(xlDown)).Select Selection.Delete Shift:=xlToLeft ActiveWindow.LargeScroll ToRight:=-5 Range("B10").Select End Sub -- GarToms |