Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Group, Is it possible to pass the contents of a cell into a comment i another cell? If so, how can I do this? Thank you for you assistance. Ton -- ajociu ----------------------------------------------------------------------- ajocius's Profile: http://www.excelforum.com/member.php...fo&userid=1769 View this thread: http://www.excelforum.com/showthread.php?threadid=39126 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Good afternoon Ajocios You can only do this via VBA - a macro. The code below will copy th contents of cell A1 into a comment contained in the currently activ cell. Sub Macro1() a = Range("A1").Value usrcell = ActiveWindow.RangeSelection.Address With Range(usrcell) .AddComment .Comment.Text Text:=a End With End Sub Post back if you want any further help in implementing this. HTH Dominic -- dominic ----------------------------------------------------------------------- dominicb's Profile: http://www.excelforum.com/member.php...fo&userid=1893 View this thread: http://www.excelforum.com/showthread.php?threadid=39126 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Is usrcell and 'a' both String types? I'm having a problem wit .AddComment. I get an error 1004. Ton -- ajociu ----------------------------------------------------------------------- ajocius's Profile: http://www.excelforum.com/member.php...fo&userid=1769 View this thread: http://www.excelforum.com/showthread.php?threadid=39126 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Hi Tony,
Try something like: Public Sub Tester02() Dim rng1 As Range, rng2 As Range Dim sStr As String Dim sh As Worksheet Set sh = ActiveSheet '<<======= CHANGE Set rng1 = sh.Range("A1") '<<======= CHANGE Set rng2 = sh.Range("B1") '<<======= CHANGE sStr = rng1.Text With rng2 If rng2.Comment Is Nothing Then .AddComment .Comment.Text Text:=sStr End If End With End Sub --- Regards, Norman "ajocius" wrote in message ... Group, Is it possible to pass the contents of a cell into a comment in another cell? If so, how can I do this? Thank you for your assistance. Tony -- ajocius ------------------------------------------------------------------------ ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695 View this thread: http://www.excelforum.com/showthread...hreadid=391261 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Hi Tony,
Try, instead: Public Sub Tester02() Dim rng1 As Range, rng2 As Range Dim sStr As String Dim sh As Worksheet Set sh = ActiveSheet '<<======= CHANGE Set rng1 = sh.Range("A1") '<<======= CHANGE Set rng2 = sh.Range("B1") '<<======= CHANGE sStr = rng1.Text With rng2 If .Comment Is Nothing Then .AddComment .Comment.Text Text:=sStr End With End Sub --- Regards, Norman "Norman Jones" wrote in message ... Hi Tony, Try something like: Public Sub Tester02() Dim rng1 As Range, rng2 As Range Dim sStr As String Dim sh As Worksheet Set sh = ActiveSheet '<<======= CHANGE Set rng1 = sh.Range("A1") '<<======= CHANGE Set rng2 = sh.Range("B1") '<<======= CHANGE sStr = rng1.Text With rng2 If rng2.Comment Is Nothing Then .AddComment .Comment.Text Text:=sStr End If End With End Sub --- Regards, Norman "ajocius" wrote in message ... Group, Is it possible to pass the contents of a cell into a comment in another cell? If so, how can I do this? Thank you for your assistance. Tony -- ajocius ------------------------------------------------------------------------ ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695 View this thread: http://www.excelforum.com/showthread...hreadid=391261 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Hi Tony What version of Excel are you using? I have just tested ths again using Excel 2000 and 2003 and it works fine. If you are using XL 97 this could be why it doesn't work, though I wasn't aware that this command wouldn't work and cannot test on 97 because I no longer have access to it. BTW, a is a variable that holds the contents of cell A1, and UsrCell the variable that holds the address of the currently active cell. Interested to know. DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=391261 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Hi Dominic,
What version of Excel are you using? I have just tested ths again using Excel 2000 and 2003 and it works fine. The sub failed for me unless I prepended the lines: AddComment Comment.Text Text:=a with a . (dot). --- Regards, Norman "dominicb" wrote in message ... Hi Tony What version of Excel are you using? I have just tested ths again using Excel 2000 and 2003 and it works fine. If you are using XL 97 this could be why it doesn't work, though I wasn't aware that this command wouldn't work and cannot test on 97 because I no longer have access to it. BTW, a is a variable that holds the contents of cell A1, and UsrCell the variable that holds the address of the currently active cell. Interested to know. DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=391261 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Norman On my system I can see the dots in front of the AddComment an Comment.Text. - I still see them now in this copied quote. In fac when I tested this piece of code I copied it straight from my postin to the VBE within Excel 2000 and 2003 without a problem. Regards DominicB dominicb Wrote: Good afternoon Ajocios You can only do this via VBA - a macro. The code below will copy th contents of cell A1 into a comment contained in the currently activ cell. Sub Macro1() a = Range("A1").Value usrcell = ActiveWindow.RangeSelection.Address With Range(usrcell) .AddComment .Comment.Text Text:=a End With End Sub Post back if you want any further help in implementing this. HTH Dominic -- dominic ----------------------------------------------------------------------- dominicb's Profile: http://www.excelforum.com/member.php...fo&userid=1893 View this thread: http://www.excelforum.com/showthread.php?threadid=39126 |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Hi Dominic,
Checking the forum in which you made your post, I see that the prepended dots were indeed included. Using my newsreader to download messages from the MS public NGs, the dots do not appear in your message. My sincere apologies for doubting! . --- Regards, Norman "dominicb" wrote in message ... Norman On my system I can see the dots in front of the AddComment and Comment.Text. - I still see them now in this copied quote. In fact when I tested this piece of code I copied it straight from my posting to the VBE within Excel 2000 and 2003 without a problem. Regards DominicB dominicb Wrote: Good afternoon Ajocios You can only do this via VBA - a macro. The code below will copy the contents of cell A1 into a comment contained in the currently active cell. Sub Macro1() a = Range("A1").Value usrcell = ActiveWindow.RangeSelection.Address With Range(usrcell) .AddComment .Comment.Text Text:=a End With End Sub Post back if you want any further help in implementing this. HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=391261 |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Hi Norman Ahhhhhhh, I see. Thanks for taking the trouble to reply - and to hunt down where my original posting came from. Appreciated. DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=391261 |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
DominicB, Below is the use of the same code you recommend. I get a run-tim error 1004 at the .AddComment line. I'm not a proven VBA programme yet, so the flow may seem not very VBA. At the top of my program: ---------------------------------------- Dim UserCell As String Dim CommentVariable As String Further down the program --------------------------------------- For Column = 3 To 52 Step 1 SheetCellPrevious2 = Sheets("Previous").Cells(Row Column).Value SheetCellCurrent2 = Sheets("Current").Cells(Row Column).Value If SheetCellCurrent2 < SheetCellPrevious2 Then Cells(Row, Column).Select CommentVariable = Cells(Row, Column).Value UserCell = ActiveWindow.RangeSelection.Address With Range(UserCell) .AddComment .Comment.Text Text:=CommentVariable End With 'Color Mismatched Cell in Largest Map With Selection.Interior .ColorIndex = 27 .Pattern = xlSolid .PatternColorIndex = xlAutomatic TotalCompareErrors = TotalCompareErrors + 1 End With Else End If ' End IF SheetCellCurrent2 < SheetCellPrevious2 Next Column Your thoughts and recommendations......... Ton -- ajociu ----------------------------------------------------------------------- ajocius's Profile: http://www.excelforum.com/member.php...fo&userid=1769 View this thread: http://www.excelforum.com/showthread.php?threadid=39126 |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
DomincB, Oh, BTW the version of Excel I'm using is 2002. Ton -- ajociu ----------------------------------------------------------------------- ajocius's Profile: http://www.excelforum.com/member.php...fo&userid=1769 View this thread: http://www.excelforum.com/showthread.php?threadid=39126 |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
DominicB, I found the error in my ways. I found it quite accidentally, maybe you could comment why this happens. Apparently the cell you insert comments cannot have comments already. That was the problem with my code. Without you seeing the spreadsheets you assumed no comments were in the sheet receiving comments. I'm sorry that I didn't make you aware of this. Nonetheless, your model is part of my program. Thank you and God Bless. Tony -- ajocius ------------------------------------------------------------------------ ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695 View this thread: http://www.excelforum.com/showthread...hreadid=391261 |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Passing Cell Contents Into Comment
Hi ajocius The fact that there might have been a comment in the cell never actually occurred to me. If you want to edit a comment, then you miss out the .AddComment command - this is only used to add a new comment. I must admit to being a little confused as to why you reported this instruction as halting the program - glad you got it sorted and pleased to have helped out in some way. Take care DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=391261 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
lookup cell reference and copy contents and comment from a range | Excel Worksheet Functions | |||
Convert cell "contents" into a "comment" | Excel Discussion (Misc queries) | |||
excel contents cells on different worksheet like a comment | Excel Discussion (Misc queries) | |||
How can I retrive the contents of a comment box in microsoft excel | Excel Discussion (Misc queries) | |||
convert cell contents into a comment | Excel Programming |