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.
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
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
 

renguer0

New Member
Joined
Jul 22, 2019
Messages
8
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.
 

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
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
 

renguer0

New Member
Joined
Jul 22, 2019
Messages
8
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:


I want to expand the cell comment on column A to every cell that can be added into dynamic table.
 

renguer0

New Member
Joined
Jul 22, 2019
Messages
8
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]
 

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
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:

renguer0

New Member
Joined
Jul 22, 2019
Messages
8
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.
 

Steve_

Board Regular
Joined
Apr 28, 2010
Messages
167
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)?
 

renguer0

New Member
Joined
Jul 22, 2019
Messages
8
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,101,850
Messages
5,483,303
Members
407,393
Latest member
GeorgeBrown

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top