Copy comment automatically on all cells in a column in a dynamic table?

renguer0

New Member
Joined
Jul 22, 2019
Messages
8
Hi. There is a way to apply the same cell comment to new rows that be created using TAB key?

Thanks for your time.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi. There is a way to apply the same cell comment to new rows that be created using TAB key?

Thanks for your time.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Row > ActiveSheet.UsedRange.Rows.Count And _
        Target.Row - ActiveSheet.UsedRange.Rows.Count = 1 Then
        If Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment Is Nothing Then
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).AddComment
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment.Visible = False
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment.Text Text:="Imma comment"
            Target.Select
        End If
    End If
End Sub
 
Upvote 0
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Row > ActiveSheet.UsedRange.Rows.Count And _
        Target.Row - ActiveSheet.UsedRange.Rows.Count = 1 Then
        If Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment Is Nothing Then
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).AddComment
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment.Visible = False
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment.Text Text:="Imma comment"
            Target.Select
        End If
    End If
End Sub
Thanks for your reply Steve. I've added this code to my sheet but the comment from first row wasn't coppied to second row when I add it with TAB key.

Maybe I didn't explained myself well. If you need I attach some screenshots to clarify what I need.
 
Upvote 0
Thanks for your reply Steve. I've added this code to my sheet but the comment from first row wasn't coppied to second row when I add it with TAB key.

Maybe I didn't explained myself well. If you need I attach some screenshots to clarify what I need.


Try this instead then..

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Row > ActiveSheet.UsedRange.Rows.Count And _
        Target.Row - ActiveSheet.UsedRange.Rows.Count = 1 Then
        If Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment Is Nothing Then
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).AddComment
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment.Visible = False
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment.Text Text:= _
            Cells(Target.Row - 1, ActiveSheet.UsedRange.Columns.Count).Comment.Text
            Target.Select
        End If
    End If
End Sub
 
Upvote 0
Try this instead then..

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Row > ActiveSheet.UsedRange.Rows.Count And _
        Target.Row - ActiveSheet.UsedRange.Rows.Count = 1 Then
        If Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment Is Nothing Then
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).AddComment
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment.Visible = False
            Cells(Target.Row, ActiveSheet.UsedRange.Columns.Count).Comment.Text Text:= _
            Cells(Target.Row - 1, ActiveSheet.UsedRange.Columns.Count).Comment.Text
            Target.Select
        End If
    End If
End Sub
Same as previous code:

Anotaci-n-2019-07-22-164524.png

I want to expand the cell comment on column A to every cell that can be added into dynamic table.
 
Upvote 0
I see that formatted comments can be copied by some VBA code but IDK how to make it automatically when dynamic table adds rows.

Code:
[COLOR=#101094][FONT=inherit]Sub[/FONT][/COLOR][COLOR=#303336][FONT=inherit] Macro[/FONT][/COLOR][COLOR=#303336][FONT=inherit]()[/FONT][/COLOR]<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">[COLOR=#303336][FONT=inherit]    Range[/FONT][/COLOR][COLOR=#303336][FONT=inherit]([/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]"A2"[/FONT][/COLOR][COLOR=#303336][FONT=inherit]).[/FONT][/COLOR][COLOR=#303336][FONT=inherit]Copy
    Range[/FONT][/COLOR][COLOR=#303336][FONT=inherit]([/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]"A3"[/FONT][/COLOR][COLOR=#303336][FONT=inherit]).[/FONT][/COLOR][COLOR=#303336][FONT=inherit]PasteSpecial Paste[/FONT][/COLOR][COLOR=#303336][FONT=inherit]:=[/FONT][/COLOR][COLOR=#303336][FONT=inherit]xlPasteComments[/FONT][/COLOR][COLOR=#303336][FONT=inherit],[/FONT][/COLOR][COLOR=#303336][FONT=inherit] Operation[/FONT][/COLOR][COLOR=#303336][FONT=inherit]:=[/FONT][/COLOR][COLOR=#303336][FONT=inherit]xlNone[/FONT][/COLOR][COLOR=#303336][FONT=inherit],[/FONT][/COLOR][COLOR=#303336][FONT=inherit] _
        SkipBlanks[/FONT][/COLOR][COLOR=#303336][FONT=inherit]:=[/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]False[/FONT][/COLOR][COLOR=#303336][FONT=inherit],[/FONT][/COLOR][COLOR=#303336][FONT=inherit] Transpose[/FONT][/COLOR][COLOR=#303336][FONT=inherit]:=[/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]False[/FONT][/COLOR][COLOR=#303336][FONT=inherit] [/FONT][/COLOR]</code>[COLOR=#101094][FONT=inherit]End[/FONT][/COLOR][COLOR=#303336][FONT=inherit] [/FONT][/COLOR][COLOR=#101094][FONT=inherit]Sub[/FONT][/COLOR]
 
Upvote 0
I see that formatted comments can be copied by some VBA code but IDK how to make it automatically when dynamic table adds rows.

When I test the code I provided, it is copying the comment from the last column down to the last column in the new row.

Do you need the comment copied somewhere else?
 
Last edited:
Upvote 0
When I test the code I provided, it is copying the comment from the last column down to the last column in the new row.

Do you need the comment copied somewhere else?
I see. I need to copy comment from first row on Tabla[A] and Tabla columns from dynamic table.
 
Upvote 0
I see. I need to copy comment from first row on Tabla[A] and Tabla columns from dynamic table.


Okay, I think I may be getting confused. Are you saying that you already have a table with the comments and rows(Table[A])...and you would like a code that will copy the comments from one table[A] into an entirely different table (Table)?
 
Upvote 0
Nope, I'm saying that I have a dynamic table named Tabla, with two columns named A and B and I want to every cell on that columns (included in dynamic table size, what increase with TAB key or moving the selector) have the same comment.

I think this action can be done copying the comment from first row on that columns but maybe there is another way to do it. In the screenshot that i've uploaded in previous post, you will see first row commented (with LIMIT text inside) but when I expand the dynamic table, the comment is not copied to the new rows of the table.

Thanks again Steve. I hope that you understand now what I want, english is not my native language but I try to explain as best as I can do.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top