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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default 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?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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?


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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!


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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!
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
Delete part of cell value Sinner Excel Programming 2 May 26th 08 10:39 PM
Delete part of a cell Francis Excel Worksheet Functions 5 February 1st 08 07:58 PM
Delete Part of Cell? Odysseus[_5_] Excel Programming 5 June 30th 05 09:31 AM
Delete Part of Cell? Odysseus[_7_] Excel Programming 1 November 1st 04 02:46 PM
Delete Part of Cell? Odysseus[_6_] Excel Programming 2 November 1st 04 02:45 PM


All times are GMT +1. The time now is 12:07 AM.

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"