Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Find & Delete

Hi. I am trying to create a macro that will search a
spreadsheet for a certain string. For each cell that
contains this string, I would like to delete the contents
of the cell.

For instance, if the string were "msn.com", I would
expect the following text strings to be found and the
cell values set to be null: ,
, and .

Any suggestions?

Thanks,
Mike.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Find & Delete

Hi Mike
try the following:

Sub find_delete()
Dim rng As Range
Dim cell As Range
Application.ScreenUpdating = False
Set rng = Selection
For Each cell In rng
If InStr(cell.Value, "msn.com") Then
cell.ClearContents
End If
Next
Application.ScreenUpdating = True
End Sub


Deletes all cells with the string 'msn.com' within your selection


--
Regards
Frank Kabel
Frankfurt, Germany

Mike wrote:
Hi. I am trying to create a macro that will search a
spreadsheet for a certain string. For each cell that
contains this string, I would like to delete the contents
of the cell.

For instance, if the string were "msn.com", I would
expect the following text strings to be found and the
cell values set to be null: ,
, and .

Any suggestions?

Thanks,
Mike.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find & Delete

Sub tester3()
Dim rng As Range
Set rng = Cells.Find(What:="msn.com", _
LookIn:=xlValues, LookAt:=xlPart)
If Not rng Is Nothing Then
Do
rng.ClearContents
Set rng = Cells.FindNext(rng)
Loop While Not rng Is Nothing
End If

End Sub




--
Regards,
Tom Ogilvy


"Mike" wrote in message
...
Hi. I am trying to create a macro that will search a
spreadsheet for a certain string. For each cell that
contains this string, I would like to delete the contents
of the cell.

For instance, if the string were "msn.com", I would
expect the following text strings to be found and the
cell values set to be null: ,
, and .

Any suggestions?

Thanks,
Mike.



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
find and delete Karen[_3_] Excel Worksheet Functions 0 March 5th 08 03:14 AM
Find and delete Karen[_3_] Excel Worksheet Functions 2 March 5th 08 02:50 AM
Find and delete Philip Drury Excel Worksheet Functions 3 October 4th 07 07:33 PM
Find and delete! Philip Drury Excel Discussion (Misc queries) 0 October 3rd 07 02:36 PM
find a value and delete that row TUNGANA KURMA RAJU Excel Discussion (Misc queries) 11 January 29th 07 09:50 AM


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

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

About Us

"It's about Microsoft Excel"