Code to find and replace words inside of a text box

R

RJR

I have Office XP with Windows XP Pro.
Is there a tool available or a work around which will allow me to edit -
find/replace words inside of a text box. I have a text box that requires
edit - find/replace each time the spreadsheet is run. I need this to be
done via VBA and would appreciate anyone providing information how to do, or
if it can be done.
------------------------------------
Related Subject: Edit - Find/replace, manual or VBA, does not work if the
cell being edited contains more than 255 characters. Is there a workaround
this? (via VBA)

I numerous cells that will contain more than 255 characters that require
Edit- Find/Replace.

Thanks in advance
BOB REYNOLDS
 
G

Guest

Turn on the macro recorder and to it manually. Turn off the macro recorder.
Study the code. You can certainly replace the hard coded argument values
with variables containing values you have elicited from the user.

If it doesn't work with more than 255 characters, then that is a limitation
(and I agree it doesn't).

You would have to go cell by cell and use the vba replace function.

this demonstrates that the vba replace works with long strings:

Sub BB()
Dim i As Long, icnt As Long
Dim s1 As String, s As String
For i = 1 To 32000
s1 = Chr(Int(Rnd() * 26 + 65))
If s1 = "A" Then icnt = icnt + 1
s = s & s1
Next
Debug.Print Len(s) - Len(Replace(s, "A", "")), icnt
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top