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.
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

stnkynts

Board Regular
Joined
Oct 7, 2010
Messages
198
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
 

jaysh

New Member
Joined
Jul 30, 2006
Messages
16
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.
 

stnkynts

Board Regular
Joined
Oct 7, 2010
Messages
198
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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,350
Messages
5,528,191
Members
409,807
Latest member
nicky736

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top