Find Value > 0

jaysh

New Member
Joined
Jul 30, 2006
Messages
16
Hopefully this is simple and I just can't find my answer.

Dim FoundCell4 As Range
Application.ScreenUpdating = False
Set FoundCell4 = Range("AS:AS").Find(what:=.Value">0") <----Need to make this work.
Do Until FoundCell4 Is Nothing
FoundCell4.EntireRow.Delete
Set FoundCell4 = Range("AS:AS").FindNext
Loop

Sorry for the n00bness.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
What you are doing in your macro is the exact same as if you were to hit cntl +F, or Find, in excel and ask it to find the exact string ".Value">0". Does this make sense why it doesn't work?

It sounds like you want to loop through a range, find the values greater than 0 and delete that entire row. Without knowing the details something like this should get you started. This is set to go through Column A and delete the entire row where column A's value is greater than 0.

Code:
Option Explicit
Sub DeleteGreaterThanZero()
Dim ws1 As Worksheet:   Set ws1 = Sheets("Sheet1")
Dim lastrow As Long
Dim icell As Long
 
lastrow = ws1.Range("A" & Rows.Count).End(xlUp).Row
 
For icell = lastrow To 1 Step -1
    If IsNumeric(ws1.Range("A" & icell)) Then
        If ws1.Range("A" & icell).Value > 0 Then
            ws1.Range("A" & icell).EntireRow.Delete Shift:=xlUp
        End If
    End If
Next icell
 
End Sub
 
Upvote 0
Now instead of deleting, how would you go about taking the value column "AT" from the trues, and adding them all up?

I hope this makes sense.
 
Upvote 0
Try:
Code:
Option Explicit
Sub DeleteGreaterThanZero()
Dim ws1 As Worksheet:   Set ws1 = Sheets("Sheet1")
Dim lastrow As Long, lastrowAT as Long
Dim icell As Long
 
lastrow = ws1.Range("A" & Rows.Count).End(xlUp).Row
 
For icell = lastrow To 1 Step -1
    If IsNumeric(ws1.Range("A" & icell)) Then
        If ws1.Range("A" & icell).Value > 0 Then
            ws1.Range("A" & icell).EntireRow.Delete Shift:=xlUp
        End If
    End If
Next icell
 
lastrowAT = ws1.Range("AT" & Rows.Count).End(xlUp).Row
ws1.Range("AT" & lastrowAT).Offset(2, 0).Formula = "=SUM(AT1: AT" & lastrowAT & ")"
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,019
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top