1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
/*********************************************************/
Sub Highlight_Cell()
Dim c As Comment
Dim ws As Worksheet
Dim i As Integer, j As Integer
i = 3
j = 8
Set ws = Application.Sheets(1)
' highlight empty cell in red
ws.Cells(i, j).Interior.Color = RGB(255, 170, 170)
ws.Cells(i, j).Font.Color = RGB(255, 0, 0)
' unlock the cell
'If ws.Cells(i, j).Locked = True Then
' ws.Cells(i, j).Locked = False
'End If
If ws.Cells(i, j).Comment Is Nothing Then
Set c = ws.Cells(i, j).AddComment
Else
Set c = ws.Cells(i, j).Comment
End If
c.Visible = True
c.Text "- Test test"
c.Shape.TextFrame.AutoSize = True
c.Shape.Shadow.Transparency = 0.5
c.Shape.Top = c.Parent.Offset(-2, 0).Top
c.Shape.Left = c.Parent.Offset(0, 2).Left - 30
' lock the cell
'ws.Cells(i, j).Locked = False
End Sub |
Partager