Find and replace in sequence

M

makulit

I have a big file with a word scattered all over. For example, the word is
"TEXT".
I want to find all of it and replace it with a sequencial number attached to
it. The result should be like, TEXT1, TEXT2, TEXT3, etc. Can this be done? I
would sure like to know. I'm using excel2007

Thanks in advance.

Julius
 
G

Gary''s Student

and if TEXT are in sentences:

Sub changeThem()
Dim s As String
s = "TEXT"
b = " "
i = 1
For Each r In ActiveSheet.UsedRange
v = r.Value
If InStr(v, s) > 0 Then
sary = Split(v, b)
For j = LBound(sary) To UBound(sary)
If sary(j) = s Then
sary(j) = sary(j) & i
i = i + 1
End If
Next
r.Value = Join(sary, b)
End If
Next
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