Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default entirerow.delete multiple text conditions

Hi,

Total newbie question here. I'd like some help with deleting entire
rows based on multiple text conditions. In hunting around on the
group, I snagged this macro, which will work for one text condition.
How can I change it to make it select all cells on the sheet named
Sheet2, look for multiple conditions and delete rows based on all of
them in a single macro?

Sub deleteWithI()
For Each myCell In Selection
If myCell = "I" Then myCell.EntireRow.Delete
Next myCell
End Sub

TIA,
Jocelyn
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default entirerow.delete multiple text conditions

Sub deleteWithMultiple()
Dim rng as Range, mycell as Range
For Each myCell In Selection
if mycell = "I" or mycell = "J" or mycell = "B" or _
mycell = "T" then
if rng is nothing then
set rng = mycell
else
set rng = Union(rng,mycell)
end if
End if
Next myCell
if not mycell is nothing then _
mycell.EntireRow.Delete
End Sub

--
Regards,
Tom Ogilvy


"Jocelyn" wrote in message
om...
Hi,

Total newbie question here. I'd like some help with deleting entire
rows based on multiple text conditions. In hunting around on the
group, I snagged this macro, which will work for one text condition.
How can I change it to make it select all cells on the sheet named
Sheet2, look for multiple conditions and delete rows based on all of
them in a single macro?

Sub deleteWithI()
For Each myCell In Selection
If myCell = "I" Then myCell.EntireRow.Delete
Next myCell
End Sub

TIA,
Jocelyn



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default entirerow.delete multiple text conditions

As written, it compiles fine for me - so you must have screwed it up in some
way when you made your changes. Perhaps if you post what you did, it can
be corrected.

--
Regards,
Tom Ogilvy


Jocelyn wrote in message
om...
Hi Tom -
For some reason, this didn't work for me. I pasted the code into a
module and replaced your I, J, B, & T with some of the elements I
wanted to remove. I selected all on the active worksheet and ran this
and got an Compile Error: End If without Block If. I inserted a line
before End Sub and put in an End If there, but it still didn't remove
the elements. Any thoughts?

Thanks,
Jocelyn

"Tom Ogilvy" wrote in message

...
Sub deleteWithMultiple()
Dim rng as Range, mycell as Range
For Each myCell In Selection
if mycell = "I" or mycell = "J" or mycell = "B" or _
mycell = "T" then
if rng is nothing then
set rng = mycell
else
set rng = Union(rng,mycell)
end if
End if
Next myCell
if not mycell is nothing then _
mycell.EntireRow.Delete
End Sub

--
Regards,
Tom Ogilvy


"Jocelyn" wrote in message
om...
Hi,

Total newbie question here. I'd like some help with deleting entire
rows based on multiple text conditions. In hunting around on the
group, I snagged this macro, which will work for one text condition.
How can I change it to make it select all cells on the sheet named
Sheet2, look for multiple conditions and delete rows based on all of
them in a single macro?

Sub deleteWithI()
For Each myCell In Selection
If myCell = "I" Then myCell.EntireRow.Delete
Next myCell
End Sub

TIA,
Jocelyn



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default entirerow.delete multiple text conditions

Tom,

To simplify matters, I opened a brand-new workbook this morning, put
the letters A to Z in Column A, and pasted the code you provided,
exactly as written, in a new module. I returned to the workbook and
ran the macro, and after I ran it, the I, J, B, and T were still
there. I went back to the code and deleted the underscores, bringing
those two long lines onto a single line, and tried again. Still no
dice. It works for you, though? Any thoughts about what else I could
be doing wrong in what seems like a pretty straightforward experiment?

Thanks a million for your help and patience.

Jocelyn

"Tom Ogilvy" wrote in message ...
As written, it compiles fine for me - so you must have screwed it up in some
way when you made your changes. Perhaps if you post what you did, it can
be corrected.

--
Regards,
Tom Ogilvy


Jocelyn wrote in message
om...
Hi Tom -
For some reason, this didn't work for me. I pasted the code into a
module and replaced your I, J, B, & T with some of the elements I
wanted to remove. I selected all on the active worksheet and ran this
and got an Compile Error: End If without Block If. I inserted a line
before End Sub and put in an End If there, but it still didn't remove
the elements. Any thoughts?

Thanks,
Jocelyn

"Tom Ogilvy" wrote in message

...
Sub deleteWithMultiple()
Dim rng as Range, mycell as Range
For Each myCell In Selection
if mycell = "I" or mycell = "J" or mycell = "B" or _
mycell = "T" then
if rng is nothing then
set rng = mycell
else
set rng = Union(rng,mycell)
end if
End if
Next myCell
if not mycell is nothing then _
mycell.EntireRow.Delete
End Sub

--
Regards,
Tom Ogilvy


"Jocelyn" wrote in message
om...
Hi,

Total newbie question here. I'd like some help with deleting entire
rows based on multiple text conditions. In hunting around on the
group, I snagged this macro, which will work for one text condition.
How can I change it to make it select all cells on the sheet named
Sheet2, look for multiple conditions and delete rows based on all of
them in a single macro?

Sub deleteWithI()
For Each myCell In Selection
If myCell = "I" Then myCell.EntireRow.Delete
Next myCell
End Sub

TIA,
Jocelyn

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
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 4 July 20th 08 11:07 AM
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 8 July 19th 08 04:45 PM
delete entirerow if date more than 12months old flow23 Excel Discussion (Misc queries) 1 May 25th 06 03:32 PM
formula to fill text with multiple conditions jerry Excel Discussion (Misc queries) 2 September 8th 05 11:26 PM
Combining Text from multiple cells under multiple conditions KNS Excel Worksheet Functions 2 June 15th 05 11:00 PM


All times are GMT +1. The time now is 08:26 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"