PC Review


Reply
Thread Tools Rate Thread

delete cell if part of cell contains

 
 
ppeer
Guest
Posts: n/a
 
      19th Oct 2009
For a worksheet I would like to check the cells if they contain the
word "text".
Within a cell this word is always combined e.g.: text 06735
When the cell contains "text" I would like to clean the whole cell, so
text including e.g: 06735.
Result: a blank cell.

Please, can somebody help me out?
 
Reply With Quote
 
 
 
 
muddan madhu
Guest
Posts: n/a
 
      19th Oct 2009
try this

Sub cleaner()
Dim rng As Range
For Each rng In ActiveSheet.UsedRange
If InStr(1, rng, "text", vbTextCompare) > 0 Then
rng.Value = Clear
End If
Next
End Sub


On Oct 19, 2:27*pm, ppeer <trafo0...@gmail.com> wrote:
> For a worksheet I would like to check the cells if they contain the
> word "text".
> Within a cell this word is always combined e.g.: text 06735
> When the cell contains "text" I would like to clean the whole cell, so
> text including e.g: 06735.
> Result: a blank cell.
>
> Please, can somebody help me out?


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      19th Oct 2009
Check your other post.

ppeer wrote:
>
> For a worksheet I would like to check the cells if they contain the
> word "text".
> Within a cell this word is always combined e.g.: text 06735
> When the cell contains "text" I would like to clean the whole cell, so
> text including e.g: 06735.
> Result: a blank cell.
>
> Please, can somebody help me out?


--

Dave Peterson
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      19th Oct 2009
I'm pretty sure this single line of code will do what you want...

Cells.Replace "*text*", "", xlPart, xlByColumns, False

--
Rick (MVP - Excel)


"ppeer" <(E-Mail Removed)> wrote in message
news:4c112a88-70f5-491b-96e5-(E-Mail Removed)...
> For a worksheet I would like to check the cells if they contain the
> word "text".
> Within a cell this word is always combined e.g.: text 06735
> When the cell contains "text" I would like to clean the whole cell, so
> text including e.g: 06735.
> Result: a blank cell.
>
> Please, can somebody help me out?


 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      19th Oct 2009
I didn't see a previous post by this person.

--
Rick (MVP - Excel)


"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Check your other post.
>
> ppeer wrote:
>>
>> For a worksheet I would like to check the cells if they contain the
>> word "text".
>> Within a cell this word is always combined e.g.: text 06735
>> When the cell contains "text" I would like to clean the whole cell, so
>> text including e.g: 06735.
>> Result: a blank cell.
>>
>> Please, can somebody help me out?

>
> --
>
> Dave Peterson


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      19th Oct 2009
Check...

From: ppeer <(E-Mail Removed)>
Newsgroups: microsoft.public.excel
Subject: delete cell if part of cell contains
Date: Mon, 19 Oct 2009 01:56:02 -0700 (PDT)


Rick Rothstein wrote:
>
> I didn't see a previous post by this person.
>
> --
> Rick (MVP - Excel)
>
> "Dave Peterson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Check your other post.
> >
> > ppeer wrote:
> >>
> >> For a worksheet I would like to check the cells if they contain the
> >> word "text".
> >> Within a cell this word is always combined e.g.: text 06735
> >> When the cell contains "text" I would like to clean the whole cell, so
> >> text including e.g: 06735.
> >> Result: a blank cell.
> >>
> >> Please, can somebody help me out?

> >
> > --
> >
> > Dave Peterson


--

Dave Peterson
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      19th Oct 2009
Ahh, okay, I see. Anyway, I still think either the code line I posted or the
equivalent Replace All from the menu bar would be good approach.

--
Rick (MVP - Excel)


"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Check...
>
> From: ppeer <(E-Mail Removed)>
> Newsgroups: microsoft.public.excel
> Subject: delete cell if part of cell contains
> Date: Mon, 19 Oct 2009 01:56:02 -0700 (PDT)
>
>
> Rick Rothstein wrote:
>>
>> I didn't see a previous post by this person.
>>
>> --
>> Rick (MVP - Excel)
>>
>> "Dave Peterson" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Check your other post.
>> >
>> > ppeer wrote:
>> >>
>> >> For a worksheet I would like to check the cells if they contain the
>> >> word "text".
>> >> Within a cell this word is always combined e.g.: text 06735
>> >> When the cell contains "text" I would like to clean the whole cell, so
>> >> text including e.g: 06735.
>> >> Result: a blank cell.
>> >>
>> >> Please, can somebody help me out?
>> >
>> > --
>> >
>> > Dave Peterson

>
> --
>
> Dave Peterson


 
Reply With Quote
 
ppeer
Guest
Posts: n/a
 
      20th Oct 2009
On 19 okt, 19:48, "Rick Rothstein"
<rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> I'm pretty sure this single line of code will do what you want...
>
> Cells.Replace "*text*", "", xlPart, xlByColumns, False
>
> --
> Rick (MVP - Excel)
>
> "ppeer" <trafo0...@gmail.com> wrote in message
>
> news:4c112a88-70f5-491b-96e5-(E-Mail Removed)...
>
>
>
> > For a worksheet I would like to check the cells if they contain the
> > word "text".
> > Within a cell this word is always combined e.g.: text 06735
> > When the cell contains "text" I would like to clean the whole cell, so
> > text including e.g: 06735.
> > Result: a blank cell.

>
> > Please, can somebody help me out?- Tekst uit oorspronkelijk bericht niet weergeven -

>
> - Tekst uit oorspronkelijk bericht weergeven -


thanks, this line of code gets the job done!
 
Reply With Quote
 
ppeer
Guest
Posts: n/a
 
      20th Oct 2009
On 19 okt, 19:48, "Rick Rothstein"
<rick.newsNO.S...@NO.SPAMverizon.net> wrote:
> I'm pretty sure this single line of code will do what you want...
>
> Cells.Replace "*text*", "", xlPart, xlByColumns, False
>
> --
> Rick (MVP - Excel)
>
> "ppeer" <trafo0...@gmail.com> wrote in message
>
> news:4c112a88-70f5-491b-96e5-(E-Mail Removed)...
>
>
>
> > For a worksheet I would like to check the cells if they contain the
> > word "text".
> > Within a cell this word is always combined e.g.: text 06735
> > When the cell contains "text" I would like to clean the whole cell, so
> > text including e.g: 06735.
> > Result: a blank cell.

>
> > Please, can somebody help me out?- Tekst uit oorspronkelijk bericht niet weergeven -

>
> - Tekst uit oorspronkelijk bericht weergeven -


and I like the minimalized code!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete cell if part of cell contains ppeer Microsoft Excel Discussion 6 19th Oct 2009 07:36 PM
Delete part of cell value Sinner Microsoft Excel Programming 0 26th May 2008 09:15 PM
Delete part of a cell Francis Microsoft Excel Worksheet Functions 5 1st Feb 2008 07:58 PM
Delete Part of Cell? Odysseus Microsoft Excel Programming 2 1st Nov 2004 03:04 PM
Delete Part of Cell? Odysseus Microsoft Excel Programming 2 1st Nov 2004 02:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:00 PM.