Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't know what's wrong!! I'm trying to delete an entire row if the word
CLOSED is found in column U here's what I have but it doesn't do anything Dim Lastrow As Long Dim row_index As Long Application.ScreenUpdating = False lastrow = ActiveSheet.Cells(Rows.Count, 21).End xlUp).Row For row_index = lastrow -21 To 21 Step -21 If Cells(row_index,21). Value = "CLOSED" Then Rows(row_index).Delete End If Next Application.ScreenUpdating = True End Sub -- Message posted via http://www.officekb.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There are a lot of 21's in that code...
Did you really mean to step in groups of 21? Did you want to start from the lastrow -21? Maybe..... Option Explicit Sub Testme() Dim Lastrow As Long Dim row_index As Long Application.ScreenUpdating = False lastrow = ActiveSheet.Cells(Rows.Count, 21).End xlUp).Row For row_index = lastrow To 1 Step -1 If ucase(Cells(row_index,21).Value) = "CLOSED" Then Rows(row_index).Delete End If Next row_index Application.ScreenUpdating = True End Sub This looks at each row (step -1) and deletes the row if closed is in column 21 (U). ps. You may want to copy directly from the code window and paste into the message--just to make sure typos aren't added to your sample code. "Ashley via OfficeKB.com" wrote: I don't know what's wrong!! I'm trying to delete an entire row if the word CLOSED is found in column U here's what I have but it doesn't do anything Dim Lastrow As Long Dim row_index As Long Application.ScreenUpdating = False lastrow = ActiveSheet.Cells(Rows.Count, 21).End xlUp).Row For row_index = lastrow -21 To 21 Step -21 If Cells(row_index,21). Value = "CLOSED" Then Rows(row_index).Delete End If Next Application.ScreenUpdating = True End Sub -- Message posted via http://www.officekb.com -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Deleting the text without deleting the formula | Excel Worksheet Functions | |||
Deleting cell data without deleting formula | Excel Discussion (Misc queries) | |||
deleting values in a worksheet without deleting the formulas | Excel Worksheet Functions | |||
how prevent formula in cell from deleting when deleting value???? | New Users to Excel | |||
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content | Excel Programming |