ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete cell if part of cell contains (https://www.excelbanter.com/excel-programming/435126-delete-cell-if-part-cell-contains.html)

ppeer

delete cell if part of cell contains
 
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?

joel[_22_]

delete cell if part of cell contains
 

Sub RemoveText()

With ActiveSheet.Cells
Set c = .Find(what:="text", _
LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
fFrstAddr = c.Address
Do
c.ClearContents

Set c = .FindNext(after:=c)
Loop While Not c Is Nothing And _
c.Address < FirstAddr
End If
End With


End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=145555


muddan madhu

delete cell if part of cell contains
 
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 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?



joel[_25_]

delete cell if part of cell contains
 

The find method I used will run much quicker especially if the used area
is large.


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=145555


Dave Peterson

delete cell if part of cell contains
 
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

Rick Rothstein

delete cell if part of cell contains
 
I'm pretty sure this single line of code will do what you want...

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

--
Rick (MVP - Excel)


"ppeer" wrote in message
...
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?



Rick Rothstein

delete cell if part of cell contains
 
I didn't see a previous post by this person.

--
Rick (MVP - Excel)


"Dave Peterson" wrote in message
...
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

delete cell if part of cell contains
 
Check...

From: ppeer
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" wrote in message
...
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

Rick Rothstein

delete cell if part of cell contains
 
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" wrote in message
...
Check...

From: ppeer
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" wrote in message
...
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



ppeer

delete cell if part of cell contains
 
On 19 okt, 19:48, "Rick Rothstein"
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" wrote in message

...



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!

ppeer

delete cell if part of cell contains
 
On 19 okt, 19:48, "Rick Rothstein"
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" wrote in message

...



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!


All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com