Thread: Deleting Rows
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
kkondrat1[_3_] kkondrat1[_3_] is offline
external usenet poster
 
Posts: 1
Default Deleting Rows


The code I am using is below-

I am trying to delete rows that contain an H in column C

here is what column "C" looks like-

H78
H78
H87
P38

The H will always appear on the left, so I am trying to use LEFT, no
sure how to do it? I tried below but it doesn't work.


Sub Delete_rows_based_on_Closing()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range, rng As Range, i As Long
Set rng = Columns("C").SpecialCells(xlConstants, xlTextValues)
For i = rng.Count To 1 Step -1
If UCase(Left(rng(i).Value)) = "H" _
And UCase(rng(i).Offset(0, 8).Value) = "CLOSING" _
Then rng(i).EntireRow.Delete
Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Su

--
kkondrat
-----------------------------------------------------------------------
kkondrat1's Profile: http://www.excelforum.com/member.php...nfo&userid=600
View this thread: http://www.excelforum.com/showthread.php?threadid=26547