Conditions in a macro
Hey there,
I am trying to have my marco delete all rows with a value equal to or less then 0 (in a particular field). Any help would be great. Thanks, -- Damon |
Conditions in a macro
Sort them first (programmatically if you wish - do a macro record to
see how), then do a find for zero, then delete all rows below. |
Conditions in a macro
Hi Damon.
Try: Sub Cancellariga() Dim R As Long Dim LR As Long With ActiveSheet LR = .Cells(Rows.Count, 1).End(xlUp).Row For R = LR To 1 Step -1 If .Cells(R, 1).Value = 0 Then .Cells(R, 1).EntireRow.Delete End If Next End With End Sub Regards Eliano On 4 Giu, 00:59, Damon wrote: Hey there, I am trying to have my marco delete all rows with a value equal to or less then 0 (in a particular field). *Any help would be great. Thanks, -- Damon |
Conditions in a macro
Sub DeleteRows()
Dim iLastRow As Long Dim I As Long iLastRow = Cells(Rows.Count, "C").End(xlUp).Row For I = iLastRow To 1 Step -1 If Cells(I, "C").Value <= 0 Then Rows(I).Delete End If Next I End Sub Edit the "C" to suit. Gord Dibben MS Excel MVP On Tue, 3 Jun 2008 15:59:02 -0700, Damon wrote: Hey there, I am trying to have my marco delete all rows with a value equal to or less then 0 (in a particular field). Any help would be great. Thanks, |
Conditions in a macro
Sorry Damon, ut i forget the minus sign.
If .Cells(R, 1).Value = 0 Then is intended as: If .Cells(R, 1).Value <= 0 Then Eliano |
Conditions in a macro
James,
I think that will work. Thank you very much. I will try that right now. -- Damon "james" wrote: Sort them first (programmatically if you wish - do a macro record to see how), then do a find for zero, then delete all rows below. |
All times are GMT +1. The time now is 09:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com