LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

 
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
Deleting several rows with given criteria Rechie Excel Discussion (Misc queries) 7 October 20th 09 01:38 PM
Deleting rows by specified criteria for duplicates Tasha Excel Discussion (Misc queries) 4 September 9th 08 10:48 AM
Deleting Rows w/ Specific Criteria MCSHMCH Excel Discussion (Misc queries) 2 September 28th 07 01:05 PM
Deleting/IDing Rows that Don't Meet Criteria LittleAndLost Excel Worksheet Functions 1 November 3rd 04 07:21 PM
Deleting rows based on criteria John Walker[_2_] Excel Programming 2 December 12th 03 08:37 PM


All times are GMT +1. The time now is 04:50 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"