Hi. There is a way to apply the same cell comment to new rows that be created using TAB key?
Thanks for your time.
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.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.
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: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
[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]
I see that formatted comments can be copied by some VBA code but IDK how to make it automatically when dynamic table adds rows.
I see. I need to copy comment from first row on Tabla[A] and Tabla columns from dynamic table.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.