まろやんの学習記録ノート📓

学んだことをアウトプットします!

セルに文字を入れる!

'
'
Private Sub Worksheet_Change(ByVal Target As Range)

Dim Cellchk, CellsData As Range

Set CellsData = Range("D2:D20") '表の範囲を把握します。

If Intersect(Target, CellsData) Is Nothing Then 'セルの変更が無いか判定します。

Exit Sub 'セルの変更がなければ、何もしない。

Else
'セルの変更が有った場合
With Cells(Target.Row, Target.Column) '変更したセルを位置を把握します。
.ClearComments 'コメントを削除します。
.AddComment
.Comment.Text Text:="" & .Value
'
With .Comment.Shape.TextFrame
.AutoSize = True
.Characters.Font.Size = 10
.Characters.Font.Bold = True
End With

End With
End If

End Sub
'