Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Delete rows that cell value is "No"

Hi and thanks in advance.

I have a range from A1:A500. The cells have Yes and No...is there anyway to
adjust my code to work? I'm trying to delete the rows that have cell value
of no.

Dim cl As String

cl = "No"

For Each cl In Range("a1:a500")
SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Next cl

thank you.

Tim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Delete rows that cell value is "No"

Sub Tester
dim rCell as Range
For each rCell in range("A1:A500")
if rCell.value="no" then rCell.Entirerow.Delete
next rCell
end sub

HTH
--
AP

"Tim" a écrit dans le message de news:
...
Hi and thanks in advance.

I have a range from A1:A500. The cells have Yes and No...is there anyway
to
adjust my code to work? I'm trying to delete the rows that have cell
value
of no.

Dim cl As String

cl = "No"

For Each cl In Range("a1:a500")
SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Next cl

thank you.

Tim



  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Delete rows that cell value is "No"

Hi Ardus! Thank you very much, it's works perfectly :)

"Ardus Petus" wrote:

Sub Tester
dim rCell as Range
For each rCell in range("A1:A500")
if rCell.value="no" then rCell.Entirerow.Delete
next rCell
end sub

HTH
--
AP

"Tim" a écrit dans le message de news:
...
Hi and thanks in advance.

I have a range from A1:A500. The cells have Yes and No...is there anyway
to
adjust my code to work? I'm trying to delete the rows that have cell
value
of no.

Dim cl As String

cl = "No"

For Each cl In Range("a1:a500")
SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Next cl

thank you.

Tim




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete rows that cell value is "No"

Hi Tim

The code Ardus posted is not correct because you must loop from the bottom up when you delete rows.
It will skip rows as it is now

See
http://www.rondebruin.nl/delete.htm


--
Regards Ron De Bruin
http://www.rondebruin.nl



"Tim" wrote in message ...
Hi Ardus! Thank you very much, it's works perfectly :)

"Ardus Petus" wrote:

Sub Tester
dim rCell as Range
For each rCell in range("A1:A500")
if rCell.value="no" then rCell.Entirerow.Delete
next rCell
end sub

HTH
--
AP

"Tim" a écrit dans le message de news:
...
Hi and thanks in advance.

I have a range from A1:A500. The cells have Yes and No...is there anyway
to
adjust my code to work? I'm trying to delete the rows that have cell
value
of no.

Dim cl As String

cl = "No"

For Each cl In Range("a1:a500")
SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Next cl

thank you.

Tim






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Delete rows that cell value is "No"

Ron is definitely right:

Sub Tester()
Dim lRow As Long
For lRow = 500 To 1 Step -1
If Cells(lRow, "A").Value = "no" Then
Rows(lRow).Delete
End If
Next lRow
End Sub


HTH
--
AP

"Ron de Bruin" a écrit dans le message de news:
...
Hi Tim

The code Ardus posted is not correct because you must loop from the bottom
up when you delete rows.
It will skip rows as it is now

See
http://www.rondebruin.nl/delete.htm


--
Regards Ron De Bruin
http://www.rondebruin.nl



"Tim" wrote in message
...
Hi Ardus! Thank you very much, it's works perfectly :)

"Ardus Petus" wrote:

Sub Tester
dim rCell as Range
For each rCell in range("A1:A500")
if rCell.value="no" then rCell.Entirerow.Delete
next rCell
end sub

HTH
--
AP

"Tim" a écrit dans le message de news:
...
Hi and thanks in advance.

I have a range from A1:A500. The cells have Yes and No...is there
anyway
to
adjust my code to work? I'm trying to delete the rows that have cell
value
of no.

Dim cl As String

cl = "No"

For Each cl In Range("a1:a500")
SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Next cl

thank you.

Tim









Reply
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
How to delete rows with "-" in cell RS Excel Discussion (Misc queries) 0 February 17th 10 04:27 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"Last Cell" to find last row, but can't delete blank rows [email protected] Excel Discussion (Misc queries) 6 January 8th 07 11:50 PM
Search for the word "continued", if found, delete that row + 10 rows above jriendeau5 Excel Programming 1 November 5th 04 02:24 AM
Search "Total" in all worksheets and delete rows containing "Total" mk_garg20 Excel Programming 2 July 30th 04 06:42 AM


All times are GMT +1. The time now is 10:39 AM.

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"