Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
find replace macro
I have a macro that finds and replaces (I found it here, thanks!) I need to
adapt it from looping through all worksheets to just cells I select. Can someone help? TIA Todd Sub FindReplace() Dim wks As Worksheet Dim WhatToReplace As String Dim WithWhat As String WhatToReplace = InputBox(Prompt:="What this time?") If WhatToReplace = "" Then Exit Sub End If WithWhat = InputBox(Prompt:="what should: " & Chr(34) & _ WhatToReplace & Chr(34) & " be replaced with?") If WithWhat = "" Then Exit Sub End If For Each wks In ActiveWorkbook.Worksheets wks.Cells.Replace what:=WhatToReplace, _ Replacement:=WithWhat, lookat:=xlPart, _ MatchCase:=False Next wks End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
find replace macro
Todd,
Replace wks.Cells.Replace ... with either an address, like wks.Range("A1:B10").Replace .... or to act on the current selection from each sheet wks.Select Selection.Replace .... HTH, Bernie MS Excel MVP "Todd L." wrote in message ... I have a macro that finds and replaces (I found it here, thanks!) I need to adapt it from looping through all worksheets to just cells I select. Can someone help? TIA Todd Sub FindReplace() Dim wks As Worksheet Dim WhatToReplace As String Dim WithWhat As String WhatToReplace = InputBox(Prompt:="What this time?") If WhatToReplace = "" Then Exit Sub End If WithWhat = InputBox(Prompt:="what should: " & Chr(34) & _ WhatToReplace & Chr(34) & " be replaced with?") If WithWhat = "" Then Exit Sub End If For Each wks In ActiveWorkbook.Worksheets wks.Cells.Replace what:=WhatToReplace, _ Replacement:=WithWhat, lookat:=xlPart, _ MatchCase:=False Next wks End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to Find and Replace | Excel Discussion (Misc queries) | |||
find&replace macro | Excel Worksheet Functions | |||
Find/replace macro | Excel Programming | |||
A Macro to Do Find and Replace | Excel Programming | |||
Using Find & Replace in macro | Excel Programming |