View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
rayd8[_2_] rayd8[_2_] is offline
external usenet poster
 
Posts: 1
Default Help - Deleting Rows on Text Criteria


I've created some code that imports a fixed width text file and format
it into columns according to field length. Some of these rows begi
with "@1" and some begin with "@2". The client only wants the rows tha
begin with "@1". No problem (so I thought), I'll just create a loop t
go through the rows and delete rows that contain "@2" in column A
Except that I can't get it to work. Here is the code I'm using:

Sub DeleteRows()
Dim i As Long
For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Cells(i, "A").Value = ["@2"] Then Cells(i
"A").EntireRow.Delete
Next i
End Sub

Nothing happens. The code executes without errors but no rows ar
deleted.

I thought maybe the worksheet wasn't active but when I add a line o
code to select a cell on the worksheet it is selected after th
procedure is finished. I also thought that maybe it was the format o
the cells so I tried formatting the column to text before the loop bu
that didn't work either. I need another set of eyes to point ou
something I think may be obvious that I'm missing. Any thoughts

--
rayd
-----------------------------------------------------------------------
rayd8's Profile: http://www.excelforum.com/member.php...fo&userid=2626
View this thread: http://www.excelforum.com/showthread.php?threadid=39709