PC Review


Reply
Thread Tools Rate Thread

Code to find and replace words inside of a text box

 
 
RJR
Guest
Posts: n/a
 
      21st Feb 2007
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




 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      21st Feb 2007
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


--
Regards,
Tom Ogilvy




"RJR" wrote:

> 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
>
>
>
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: find capitalized words and replace with a text Octavio Microsoft Word New Users 1 2nd Sep 2009 03:33 PM
Re: find capitalized words and replace with a text Greg Maxey Microsoft Word New Users 1 2nd Sep 2009 01:16 AM
Re: find capitalized words and replace with a text Terry Farrell Microsoft Word New Users 1 1st Sep 2009 09:12 PM
find & replace a word and change text color of found words Der Koalameister Microsoft Word Document Management 1 30th May 2008 08:02 PM
Need to find and replace text inside a macro using vba filet2050 Microsoft Excel Programming 2 5th Dec 2007 12:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:01 PM.