text box

E

Ed

What do I have to add to the below code so that it changes all occurrances in
a text box as well as multiple text boxes?



Sub textbox()
Dim FromStr As String
Dim ToStr As String
Dim TB As textbox
Dim wks As Worksheet

FromStr = "703b"
ToStr = "800L"

Set wks = ActiveSheet

With wks
For Each TB In .TextBoxes
With TB
.Text = Replace(expression:=.Text, _
Find:=FromStr, _
Replace:=ToStr, _
Start:=1, _
Count:=1, _
compare:=vbTextCompare)
End With
Next TB
End With










End Sub
 
J

JE McGimpsey

Ed said:
What do I have to add to the below code so that it changes all occurrances in
a text box as well as multiple text boxes?

FIrst, since you're using the VBA6 Replace method, I'll assume that
you're not using XL for Macintosh, which is the subject of this
newsgroup (hence the ".mac." in the title). For future reference a
better group for WinXL specific questions would be

microsoft.public.excel.programming

However, the answer to your question is to delete the

.Count:=1, _

line from your code.
 
E

Ed

Hi JE McGimpsey,

Thanks for answering my question and thanks for pointing out that I was in
the wrong group.
 

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