Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Delete row macro/VB

I'm looking for a macro/VB code that will evaluate a cell
and if it meets the criteria, will delete the row.

For example, if cell c5=0, then delete that row.

Can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Delete row macro/VB

Dave here is one way,

Sub Delete_0()

' This macro deletes all rows on the active worksheet
' in column C where the valve is 0
Dim iRow As Long
Dim SpecValue As String

SpecValue = 0

If SpecValue = "" Then Exit Sub

For iRow = ActiveSheet.UsedRange.Rows.Count To 1 Step -1
If Cells(iRow, 3) = SpecValue Then Rows(iRow).Delete
Next iRow

End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 2003
** remove news from my email address to reply by email **
"Dave" wrote in message
...
I'm looking for a macro/VB code that will evaluate a cell
and if it meets the criteria, will delete the row.

For example, if cell c5=0, then delete that row.

Can anyone help?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete row macro/VB

Hi Dave,

Try:

Sub Tester()
Dim rng As Range
Set rng = Range("C5")
If rng.Value = 0 Then rng.EntireRow.Delete
End Sub


---
Regards,
Norman



"Dave" wrote in message
...
I'm looking for a macro/VB code that will evaluate a cell
and if it meets the criteria, will delete the row.

For example, if cell c5=0, then delete that row.

Can anyone help?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Delete row macro/VB

Here is one way

Sub RowZapper()
If Sheet1.Range("c5") = 0 Then
Sheet1.Range("c5").EntireRow.Delete
End If
End Sub

Christy;)

"Dave" wrote:

I'm looking for a macro/VB code that will evaluate a cell
and if it meets the criteria, will delete the row.

For example, if cell c5=0, then delete that row.

Can anyone help?

  #5   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default Delete row macro/VB

HI

Write code to iterrate through column C or per examle set C5 as activecell
then the following code will do the job


If ActiveCell.Value = "0" Then Selection.EntireRow.Delete

There are other varients of this code

Best N10


"Dave" wrote in message
...
I'm looking for a macro/VB code that will evaluate a cell
and if it meets the criteria, will delete the row.

For example, if cell c5=0, then delete that row.

Can anyone help?



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004


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
Macro warning - how to delete macro GavinS Excel Worksheet Functions 3 April 1st 09 01:45 PM
delete a macro that isn't in macro list Jane Makinson Excel Discussion (Misc queries) 3 March 13th 06 01:10 PM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM


All times are GMT +1. The time now is 03:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"