Hello, I am hoping someone can help with my query.I have rows of data containing at least 5 columns.What I want to do is use an if statement on two columns such as If F4>4 and G4<8 than I want to retain that row.The rows that do not meet this criteria I want to delete those complete rows. Is this possible in an if statement.
Gil
Hi,
No ...
A formula will only allow you to spot the rows to be deleted ...
To delete these rows, you will need a macro ...
HTH
You could do it in VBA with a command button or Macro Keys
This macro could be modified to suit
Just insert in a standard vba module and adapt to suit - Try it in a copy of your workbook. You can't undo macro results.Sub DeleteRowsWithConditionFalse() Dim LR As Long, i As Integer, c1 As Integer, c2 As Integer LR = Range("F" & Rows.Count).End(xlUp).Row c1 = Range("F1").Column c2 = Range("G1").Column For i = LR To 1 Step -1 If Cells(i, c1).Value > 4 And Cells(i, c2).Value < 8 Then 'Do nothing Else Rows(i).EntireRow.Delete xlShiftUp End If Next i End Sub
Alternatively - use Auto Filter........
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks