VBA code to delete row based on vaule of one cell within that row?

VBA code to delete row based on vaule of one cell within that row?

Post by Galen Ligh » Sat, 19 Feb 2000 04:00:00



HI!
I am writing a little macro in Excel 97 and I have hit a little block.
I am sure this is do-able, I just lack the knowledge.
I have a cell (well actually I have a worksheet full of cells, but I
think I can work out the looping from one cell to the next...) that
contains a numerical value that is either positive or negative.
If the value is 0 or negitive I want the macro to delete the entire row.
Any suggestions? Thanks in advance!

Galen

 
 
 

VBA code to delete row based on vaule of one cell within that row?

Post by gkno.. » Sat, 19 Feb 2000 04:00:00


Maybe something like:

Dim c As Range
    For Each c In ActiveSheet.UsedRange.Cells
        If IsNumeric(c.Value) and c.Value <= 0 Then
                c.EntireRow.Delete
        End If
    Next c

...which will check every cell in the range. If any cell has a zero or
less, the row is history.

Gary



:HI!
:I am writing a little macro in Excel 97 and I have hit a little block.
:I am sure this is do-able, I just lack the knowledge.
:I have a cell (well actually I have a worksheet full of cells, but I
:think I can work out the looping from one cell to the next...) that
:contains a numerical value that is either positive or negative.
:If the value is 0 or negitive I want the macro to delete the entire row.
:Any suggestions? Thanks in advance!
:
:Galen

 
 
 

1. deleting duplicate rows and inserting rows based on cell differences

Hi,  someone have solutions to the following problems:

1)  I want to be able to delete entire rows which are identical to each other.  
The rows that would be identical would be one on top of another and I only
have to compare 4 or 5 cells from each row to determine if they are identical.

and then once these identical rows are deleted...

2) I would like to be able to insert rows between other rows based on the
information contained in one column.  e.g.  a list sorted by date where I will
be able to insert a couple of lines between different dates,  separating the
days if you will.

Thanks for any information.
Bert

2. Problemi Euro -> lire

3. VBA code to delete entire row based on missing value

4. Associate one buffer with two files

5. SQL: delete rows based on a column being like-compared to other rows

6. Traffic Shapping

7. Highlighting single rows or one object within a row

8. Mac-based Transcription software anywhere?

9. EXCEL'97 VBA- Find and Delete Rows based on data in spreadsheet

10. VBA code for Iif Function to delete rows meeting certain criteria

11. ***Macro Code Required to delete Zero value cell and its row***

12. Vba Code Required for Delete Entire Row

13. VBA code to add ONE row at the end of a named range ?