Sub Macro2()
r = Selection.Row: nr = Selection.Rows.Count
c = Selection.Column: nc = Selection.Columns.Count
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
Range(Cells(r, c), Cells(r + nr - 1, c + nc - 1)).Select
Cells(r, c).AddComment
Cells(r, c).Comment.Visible = False
Cells(r, c).Comment.Text Text:="hello world"
Cells(r, c).Interior.ColorIndex = 4 ' change to suit
End Sub
Sub MergeCells()
Dim Cell As Range, FirstCell As Range, First As Boolean, Contents As String
First = True
For Each Cell In Selection
If First = True Then
Set FirstCell = Cell
First = False
End If
Contents = Contents & " " & Cell
Next Cell
Selection.ClearContents
Selection.Interior.ColorIndex = 12
FirstCell = Contents & " " & InputBox("User Comment")
End Sub
Sub test_code()
r = Selection.Row: nr = Selection.Rows.Count
c = Selection.Column: nc = Selection.Columns.Count
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
Range(Cells(r, c), Cells(r + nr - 1, c + nc - 1)).Select
Cells(r, c).AddComment
Cells(r, c).Comment.Visible = False
Cells(r, c).Comment.Text Text:=InputBox("Please enter comment")
Cells(r, c).Interior.ColorIndex = 4 ' change to suit
End Sub