replace in a split?

K

Kevin

If i have a cell with a comment in it and that comment has say 4 lines :
one
two
three
four

I know I can refer to a single line by using
Range(CurrAddress).Comment.text, vbLf)(2) which would refer to "Three"

But what if i want to replace the "three" with "someting else"?

Range(CurrAddress).Comment.text, vbLf)(2)="Something Else" doesn't work....

Thanks in advance
Kevin Green
 
G

Gary''s Student

I put your stuff in C8

Sub stitute()
Dim r As Range, s As String
Set r = Range("C8")
s = r.Comment.Text
pieces = Split(s, Chr(10))
pieces(2) = "something else"
r.Comment.Text Text:=Join(pieces, Chr(10))
End Sub
 
K

Kevin

NICE!!! I like it.. I especially like your macro name!! :)

Thank you much for the help..
 

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