Private Sub CommandButton1_Click()
Dim dn As Long
ng = TextBox1
soho = TextBox2
If ng = 0 Or soho = "" Then GoTo moi
With Range("a1:a500")
Set c = .Find(soho, LookIn:=xlValues)
If Not c Is Nothing Then
End If
End With
If OptionButton1 = True Then
k = ((ng - 1) * 4 + 2) + (ng - 1) * 4
dn = c.Offset(, k + 3)
c.Offset(, k) = c.Offset(, k).Value + Val(TextBox4)
c.Offset(, k + 1) = c.Offset(, k + 1).Value + Val(TextBox6)
c.Offset(, k + 2) = c.Offset(, k + 2).Value + Val(TextBox7)
Else
k = ((ng - 1) * 4 + 2) + (ng - 1) * 4
dn = c.Offset(, k + 7)
c.Offset(, k + 4) = c.Offset(, k + 4).Value + Val(TextBox4)
c.Offset(, k + 5) = c.Offset(, k + 5).Value + Val(TextBox6)
c.Offset(, k + 6) = c.Offset(, k + 6).Value + Val(TextBox7)
k = k + 4
End If
If dn > 0 And Val(TextBox4) + Val(TextBox6) + Val(TextBox7) > 0 Then _
Range(c.Offset(, k), c.Offset(, k + 2)).Interior.ColorIndex = 7
chuoi = "< " & TextBox4 & " > < " & TextBox6 & " > < " & TextBox7 & " > ---" & Now()
With c.Offset(, k + 3)
If dn = 0 Then
.AddComment
.Comment.Text Text:=chuoi
.Comment.Visible = False
Else
chuoi = .Comment.Text & Chr(10) & chuoi
.Comment.Text Text:=chuoi
End If
End With
moi:
luong1 = 0: luong2 = 0: luong3 = 0: luong4 = 0
TextBox2 = "": TextBox4 = 0: TextBox6 = 0: TextBox7 = 0
TextBox3 = ""
TextBox2.SetFocus
End Sub