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 40 41 42 43 44 45 46 47 48 49
| Private Sub CommandButton1_Click()
Dim Z, Y, W As String
Y = Environ("username") & ": "
If CommandButton1.Caption = ("Insert Comment") Then
CommandButton1.Caption = ("Save")
Z = ThisWorkbook.Worksheets("Dashboard").Range("B" & BB).Offset(0, 16 + ComboBox2.ListIndex)
With TextBox1
.Locked = False
.SetFocus
.EnterKeyBehavior = True
.BackColor = -2147483643
.SpecialEffect = fmSpecialEffectSunken
.MousePointer = fmMousePointerDefault
End With
If Len(Z) - Len(Y) > 0 Then
W = Z & Chr(10) & Chr(10) & Y
Else
W = Y
End If
TextBox1.Value = W
Else
If Len(TextBox1.Value) - Len(Y) > 0 Then
If Right(TextBox1.Value, Len(Y)) = Y Then
TextBox1.Value = ThisWorkbook.Worksheets("Dashboard").Range("B" & BB).Offset(0, 16 + ComboBox2.ListIndex)
End If
Else
TextBox1.Value = ""
End If
ThisWorkbook.Worksheets("Dashboard").Range("B" & BB).Offset(0, 16 + ComboBox2.ListIndex) = TextBox1.Value
CommandButton1.Caption = ("Insert Comment")
With TextBox1
.BackColor = -2147483633
.SpecialEffect = fmSpecialEffectSunken
.Locked = True
.MousePointer = fmMousePointerArrow
End With
End If
End Sub |
Partager