Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Modifying Macro - Merge multiple sheets based on a condition ScottMSP Excel Programming 4 November 18th 08 09:14 PM
Macro to delete rows based on a condition Darrilyn Excel Worksheet Functions 1 September 6th 07 12:12 AM
macro to delete rows on condition Todd Excel Programming 1 August 24th 06 11:44 PM
how do I delete all rows that match a condition? djhs63 Excel Worksheet Functions 5 March 16th 05 03:55 PM
delete rows with certain condition Grey Excel Programming 2 December 19th 03 12:05 PM


All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"