Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
find and delete | Excel Worksheet Functions | |||
Find and delete | Excel Worksheet Functions | |||
Find and delete | Excel Worksheet Functions | |||
Find and delete! | Excel Discussion (Misc queries) | |||
find a value and delete that row | Excel Discussion (Misc queries) |