Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
HELP modifying macro to delete rows if more than 1 condition met &
I got his code and it works fine but wondering if it can be modified to
delete not only rows that have "TRUE" in column in A but other 3 or 4 different calues in column B... Sub UPDATE_TENURE() Dim MyRange, MyRange1 As Range Dim LastRow As Long Set Sht = Sheets("Agent Tenure") LastRow = Sht.Cells(Rows.Count, "A").End(xlUp).Row Set MyRange = Sht.Range("A1:A" & LastRow) For Each c In MyRange If UCase(c.Value) = "TRUE" Then If MyRange1 Is Nothing Then Set MyRange1 = c.EntireRow Else Set MyRange1 = Union(MyRange1, c.EntireRow) End If End If Next If Not MyRange1 Is Nothing Then MyRange1.Delete End If End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
HELP modifying macro to delete rows if more than 1 condition met &
Yes, it can be modified. You didn't say what your other conditions are, but
generally you would OR them into this line of code... If UCase(c.Value) = "TRUE" Then For example... If UCase(c.Value) = "TRUE" Or UCase(c.Value) = "NewCondition" Then Just keep OR'ing your new conditions in the same way I added the "NewCondition" above. -- Rick (MVP - Excel) "Mayte" wrote in message ... I got his code and it works fine but wondering if it can be modified to delete not only rows that have "TRUE" in column in A but other 3 or 4 different calues in column B... Sub UPDATE_TENURE() Dim MyRange, MyRange1 As Range Dim LastRow As Long Set Sht = Sheets("Agent Tenure") LastRow = Sht.Cells(Rows.Count, "A").End(xlUp).Row Set MyRange = Sht.Range("A1:A" & LastRow) For Each c In MyRange If UCase(c.Value) = "TRUE" Then If MyRange1 Is Nothing Then Set MyRange1 = c.EntireRow Else Set MyRange1 = Union(MyRange1, c.EntireRow) End If End If Next If Not MyRange1 Is Nothing Then MyRange1.Delete End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help Modifying Macro - Merge multiple sheets based on a condition | Excel Programming | |||
Macro to delete rows based on a condition | Excel Worksheet Functions | |||
macro to delete rows on condition | Excel Programming | |||
how do I delete all rows that match a condition? | Excel Worksheet Functions | |||
delete rows with certain condition | Excel Programming |