Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default How to loop

I have Columns A:G and many cells I want to delete entire Rows if the content
of the cell contaings certain word. So far I got this Macro, but it does not
loop and I have to run it several times to get it right. is there any way I
could run it once?

Note: the code below looks at cell A2:G2 and deletes the whole Row

Sub DeleteColumns()
Dim i As Integer

For i = 256 To 1 Step -1
If Cells(2, i).Text = "Subtotal of High" Or _
Cells(2, i).Text = "Subtotal of Extremely High" Or _
Cells(2, i).Text = "Subtotal of Average" Or _
Cells(2, i).Text = "Subtotal of Below Average" Or _
Cells(2, i).Text = "Subtotal of Above Average" Or _
Cells(2, i).Text = "Grand Total" Then
Cells(2, i).EntireRow.Delete
End If
Next i
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200707/1

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DO LOOP in VBA Brettjg Excel Discussion (Misc queries) 5 April 24th 07 12:42 AM
help with a loop BeJay Excel Discussion (Misc queries) 3 May 19th 06 12:24 PM
Do Loop BobBarker Excel Worksheet Functions 0 August 19th 05 08:44 PM
Do Loop BobBarker Excel Worksheet Functions 0 August 19th 05 07:45 PM
Do Loop BobBarker Excel Worksheet Functions 0 August 19th 05 06:54 PM


All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"