Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim col As Range
Dim str As String
Application.EnableEvents = False
Set rng = Intersect(Target, Range("4:5"))
If Not rng Is Nothing Then
For Each col In rng.Columns
If IsNumeric(Cells(4, col.Column)) And Cells(5, col.Column) <> "" And IsNumeric(Cells(4, col.Column)) And Cells(5, col.Column) <> "" Then
str = Cells(4, col.Column) - Cells(5, col.Column) & ", (Variance to Allowed)"
With Cells(4, col.Column)
.ClearComments
.AddComment
.Comment.Visible = False
.Comment.Text Text:=str
.Comment.Shape.TextFrame.AutoSize = True
End With
End If
Next
End If
Application.EnableEvents = True
End Sub
Sub iniall()
Dim rng As Range
Dim cel As Range
Set rng = Range("4:4")
For Each cel In rng.Cells
If IsNumeric(cel) And cel.Offset(1, 0) <> "" And IsNumeric(cel) And cel.Offset(1, 0) <> "" Then
cel = cel
End If
Next
End Sub
|