PC Review


Reply
Thread Tools Rate Thread

Conditions in a macro

 
 
Damon
Guest
Posts: n/a
 
      3rd Jun 2008
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
 
Reply With Quote
 
 
 
 
james
Guest
Posts: n/a
 
      4th Jun 2008
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.
 
Reply With Quote
 
eliano
Guest
Posts: n/a
 
      4th Jun 2008
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 <Da...@discussions.microsoft.com> 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


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      4th Jun 2008
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 <(E-Mail Removed)>
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,


 
Reply With Quote
 
eliano
Guest
Posts: n/a
 
      4th Jun 2008
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
 
Reply With Quote
 
Damon
Guest
Posts: n/a
 
      4th Jun 2008
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.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Conditions Emma Hope Microsoft Access Macros 1 20th Aug 2009 06:40 AM
Macro Conditions =?Utf-8?B?UkFP?= Microsoft Access Macros 5 19th Oct 2006 12:17 AM
Macro conditions stop macro =?Utf-8?B?VG9tUg==?= Microsoft Access Macros 1 31st Aug 2006 07:58 PM
Macro Conditions =?Utf-8?B?R2xlbm4=?= Microsoft Access 2 17th Nov 2005 05:58 PM
Macro conditions help Robert Williamson Microsoft Access Macros 1 21st Nov 2003 01:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:03 PM.