ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to insert comment (https://www.excelbanter.com/excel-programming/427493-macro-insert-comment.html)

theo

macro to insert comment
 
Hi all - I've been looking for some sample code to do the following.

I'm looking for a macro that will first check if the cell in column E has
data; if it does, I want to cut the data (it will be txt) from the cell in
column E and insert it as a comment in column A, and do that for each row in
the worksheet. I looked through this site and Contextures and couldn't find a
sample.

Any help always appreciated!
Theo

Jacob Skaria

macro to insert comment
 
Dear Theo

Try the below macro

Sub Macro1()

Adjust the number of rows as per your requirement

For lngRow = 1 To 100
If Trim(Range("E" & lngRow)) < "" Then
Range("A" & lngRow).ClearComments
Range("A" & lngRow).AddComment Range("E" & lngRow).Text
Range("E" & lngRow) = ""
End If
Next

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Theo" wrote:

Hi all - I've been looking for some sample code to do the following.

I'm looking for a macro that will first check if the cell in column E has
data; if it does, I want to cut the data (it will be txt) from the cell in
column E and insert it as a comment in column A, and do that for each row in
the worksheet. I looked through this site and Contextures and couldn't find a
sample.

Any help always appreciated!
Theo


theo

macro to insert comment
 
Thanks Jacob - that was short and sweet. Works great.
Theo

"Jacob Skaria" wrote:

Dear Theo

Try the below macro

Sub Macro1()

Adjust the number of rows as per your requirement

For lngRow = 1 To 100
If Trim(Range("E" & lngRow)) < "" Then
Range("A" & lngRow).ClearComments
Range("A" & lngRow).AddComment Range("E" & lngRow).Text
Range("E" & lngRow) = ""
End If
Next

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Theo" wrote:

Hi all - I've been looking for some sample code to do the following.

I'm looking for a macro that will first check if the cell in column E has
data; if it does, I want to cut the data (it will be txt) from the cell in
column E and insert it as a comment in column A, and do that for each row in
the worksheet. I looked through this site and Contextures and couldn't find a
sample.

Any help always appreciated!
Theo



All times are GMT +1. The time now is 11:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com