Copy comment automatically on all cells in a column in a dynamic table?
Results 1 to 10 of 10

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

  1. #1
    New Member
    Join Date
    Jul 2019
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    Hi. There is a way to apply the same cell comment to new rows that be created using TAB key?

    Thanks for your time.

  2. #2
    Board Regular
    Join Date
    Apr 2010
    Posts
    167
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by renguer0 View Post
    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

  3. #3
    New Member
    Join Date
    Jul 2019
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by Steve_ View Post
    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.

  4. #4
    Board Regular
    Join Date
    Apr 2010
    Posts
    167
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by renguer0 View Post
    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

  5. #5
    New Member
    Join Date
    Jul 2019
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by Steve_ View Post
    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.

  6. #6
    New Member
    Join Date
    Jul 2019
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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:
    Sub Macro()    Range("A2").Copy
        Range("A3").PasteSpecial Paste:=xlPasteComments, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=FalseEndSub

  7. #7
    Board Regular
    Join Date
    Apr 2010
    Posts
    167
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by renguer0 View Post
    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 by Steve_; Jul 22nd, 2019 at 05:34 PM.

  8. #8
    New Member
    Join Date
    Jul 2019
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by Steve_ View Post
    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[B] columns from dynamic table.

  9. #9
    Board Regular
    Join Date
    Apr 2010
    Posts
    167
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

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

    Quote Originally Posted by renguer0 View Post
    I see. I need to copy comment from first row on Tabla[A] and Tabla[B] 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[B])?

  10. #10
    New Member
    Join Date
    Jul 2019
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •