PDA

View Full Version : Find & Replace VBA help



gismoid
08-29-2008, 01:25 AM
As clear as mud? I hope someone can help me with this as i'm relatively new to vba.

Here is the code first:

Option Explicit

Sub ChgInfo()

Dim WS As Worksheet
Dim Search As String
Dim Replacement As String
Dim Prompt As String
Dim Title As String
Dim MatchCase As Boolean

Prompt = "What is the original value you want to replace?"
Title = "Search Value Input"
Search = InputBox(Prompt, Title)


Prompt = "What is the replacement value?"
Title = "Search Value Input"
Replacement = InputBox(Prompt, Title)

At this point i get a popup asking me for the file path? I have to close it by pressing the 'x' or 'cancel'? Can someone help me with the code to close these? I realise that it's looking for external data, but i'm just hoping there is some code to close these windows. The code works fine once you have closed the 26 windows.



For Each WS In Worksheets
WS.Cells.Replace What:=Search, Replacement:=Replacement, _
LookAt:=xlPart, MatchCase:=False
Next

End Sub



I hope this has made some sense?

darthobra
08-29-2008, 10:32 AM
gismoid,

I was able to run the code without a problem. What windows are you referring to?

Darth