Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert comment into cell
Dear Expert,
Have 2 columns .... Column A is name Column B is type I want the content in column B to put as comments in respective column A. For example, Name Type Elton PT Jasmine PT Tony FT, 10 Kammi PT, 12 Would like to put PT as comment in cell A2 (Elton) Would like to put PT as comment in cell A3 (Jasmine) Would like to put FT, 10 as comment in cell A4 (Tony) It can certainly be done manually ... by copy, right click the cell, choose insert comment .....repeat and repeat ... I have 1000 cells to be done. Hope VBA can automate the task. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert comment into cell
Hi,
Try this macro Sub No_Comment() Dim c As Range Dim LastRow As Long Set Sht = Sheets("Sheet1") ' change to suit LastRow = Sht.Cells(Cells.Rows.Count, "A").End(xlUp).Row Set MyRange = Sht.Range("A2:A" & LastRow) For Each c In MyRange With c If .Comment Is Nothing Then .AddComment c.Offset(, 1).Value End If End With Next End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Elton Law" wrote: Dear Expert, Have 2 columns .... Column A is name Column B is type I want the content in column B to put as comments in respective column A. For example, Name Type Elton PT Jasmine PT Tony FT, 10 Kammi PT, 12 Would like to put PT as comment in cell A2 (Elton) Would like to put PT as comment in cell A3 (Jasmine) Would like to put FT, 10 as comment in cell A4 (Tony) It can certainly be done manually ... by copy, right click the cell, choose insert comment .....repeat and repeat ... I have 1000 cells to be done. Hope VBA can automate the task. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert comment into cell
Hi Mike,
It does not work. Stop here .... debug ... highlight this part. Can you help? ..AddComment c.Offset(, 1).Value Thanks "Mike H" wrote: Hi, Try this macro Sub No_Comment() Dim c As Range Dim LastRow As Long Set Sht = Sheets("Sheet1") ' change to suit LastRow = Sht.Cells(Cells.Rows.Count, "A").End(xlUp).Row Set MyRange = Sht.Range("A2:A" & LastRow) For Each c In MyRange With c If .Comment Is Nothing Then .AddComment c.Offset(, 1).Value End If End With Next End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Elton Law" wrote: Dear Expert, Have 2 columns .... Column A is name Column B is type I want the content in column B to put as comments in respective column A. For example, Name Type Elton PT Jasmine PT Tony FT, 10 Kammi PT, 12 Would like to put PT as comment in cell A2 (Elton) Would like to put PT as comment in cell A3 (Jasmine) Would like to put FT, 10 as comment in cell A4 (Tony) It can certainly be done manually ... by copy, right click the cell, choose insert comment .....repeat and repeat ... I have 1000 cells to be done. Hope VBA can automate the task. Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert comment into cell
Mike's code worked ok for me (well, after I dimmed a couple more variables,
<vbg). So... Did you change his code? Is your worksheet protected? Do you have errors in those adjacent cells? If you changed his code, post your new version. If your worksheet is protected, unprotect it first (either in code or manually) and try again. If you have errors in those adjacent cells, try using: ..AddComment c.Offset(, 1).Text Elton Law wrote: Hi Mike, It does not work. Stop here .... debug ... highlight this part. Can you help? .AddComment c.Offset(, 1).Value Thanks "Mike H" wrote: Hi, Try this macro Sub No_Comment() Dim c As Range Dim LastRow As Long Set Sht = Sheets("Sheet1") ' change to suit LastRow = Sht.Cells(Cells.Rows.Count, "A").End(xlUp).Row Set MyRange = Sht.Range("A2:A" & LastRow) For Each c In MyRange With c If .Comment Is Nothing Then .AddComment c.Offset(, 1).Value End If End With Next End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Elton Law" wrote: Dear Expert, Have 2 columns .... Column A is name Column B is type I want the content in column B to put as comments in respective column A. For example, Name Type Elton PT Jasmine PT Tony FT, 10 Kammi PT, 12 Would like to put PT as comment in cell A2 (Elton) Would like to put PT as comment in cell A3 (Jasmine) Would like to put FT, 10 as comment in cell A4 (Tony) It can certainly be done manually ... by copy, right click the cell, choose insert comment .....repeat and repeat ... I have 1000 cells to be done. Hope VBA can automate the task. Thanks -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert comment into cell
Thanks mike and dave ....
It works now. Thanks .... "Dave Peterson" wrote: Mike's code worked ok for me (well, after I dimmed a couple more variables, <vbg). So... Did you change his code? Is your worksheet protected? Do you have errors in those adjacent cells? If you changed his code, post your new version. If your worksheet is protected, unprotect it first (either in code or manually) and try again. If you have errors in those adjacent cells, try using: ..AddComment c.Offset(, 1).Text Elton Law wrote: Hi Mike, It does not work. Stop here .... debug ... highlight this part. Can you help? .AddComment c.Offset(, 1).Value Thanks "Mike H" wrote: Hi, Try this macro Sub No_Comment() Dim c As Range Dim LastRow As Long Set Sht = Sheets("Sheet1") ' change to suit LastRow = Sht.Cells(Cells.Rows.Count, "A").End(xlUp).Row Set MyRange = Sht.Range("A2:A" & LastRow) For Each c In MyRange With c If .Comment Is Nothing Then .AddComment c.Offset(, 1).Value End If End With Next End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "Elton Law" wrote: Dear Expert, Have 2 columns .... Column A is name Column B is type I want the content in column B to put as comments in respective column A. For example, Name Type Elton PT Jasmine PT Tony FT, 10 Kammi PT, 12 Would like to put PT as comment in cell A2 (Elton) Would like to put PT as comment in cell A3 (Jasmine) Would like to put FT, 10 as comment in cell A4 (Tony) It can certainly be done manually ... by copy, right click the cell, choose insert comment .....repeat and repeat ... I have 1000 cells to be done. Hope VBA can automate the task. Thanks -- Dave Peterson . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Insert comment to Cell | Excel Discussion (Misc queries) | |||
Insert a File, not a Comment, to a Cell | Excel Programming | |||
Macro to Insert Comment to a cell | Excel Programming | |||
Macro to Insert Comment to a cell | Excel Programming | |||
How do I insert a comment when the Insert:Comment menu is greyed? | Excel Discussion (Misc queries) |