Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default replace in a split?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default replace in a split?

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
--
Gary''s Student - gsnu200830


"Kevin" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default replace in a split?

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

Thank you much for the help..

"Gary''s Student" wrote:

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
--
Gary''s Student - gsnu200830


"Kevin" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default replace in a split?


Very neat!


--
mdmackillop
------------------------------------------------------------------------
mdmackillop's Profile: http://www.thecodecage.com/forumz/member.php?userid=113
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=57722

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace - Replace with Blank Space Studebaker Excel Discussion (Misc queries) 4 April 3rd 23 10:55 AM
How do I remove split a split window? Norm New Users to Excel 3 July 19th 08 10:31 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Using Find and Replace to replace " in a macro snail30152 Excel Programming 1 April 13th 06 11:58 PM
Replace method - cannot find any data to replace Mike Excel Programming 5 April 6th 06 08:56 PM


All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"