提供部分VBA源代码给你,可以自己放到一个宏中,略作修改即可(公式部分有报错异常时,找出原因处理一下)。
Dim i,j,v,tSheets("AAA").Select
i=ActiveSheet.UsedRange.rows.count
t=ActiveSheet.Rows(1).Find("*", , , , 2, 2).column
For i = 1 to ActiveSheet.UsedRange.rows().count
Dim i, j, v, t
Sheets("AAA").Select
i = ActiveSheet.UsedRange.Rows.Count
t = ActiveSheet.Rows(1).Find("*", , , , 2, 2).Column
For i = 1 To ActiveSheet.UsedRange.Rows().Count
For j = 1 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column()
v = Cells(i, j)
If IsNumeric(v) Then
'On Error Resume Next
Cells(1, t).FormulaR1C1 = "=IFERROR(VLOOKUP(IFERROR(VLOOKUP("""" & " & Cells(1, j) & ",定义表!C3:C4,2,0),0)&""" & Cells(i, 2) & """,数据处理表!C3:C6,4,0),"""")"
v = Cells(1, t).Value
If v <> "" Then
Cells(i, j).ClearComments
Cells(i, j).AddComment Cells(1, t).Value
'Cells(i, j).Comment.Visible = True
Cells(1, t) = ""
End If
End If
Next j
Next i
Private Sub Worksheet_Change(ByVal Target As Range)If Intersect(Target, Range("e8:q51")) Is Nothing Then Exit Sub
If Target.Count >1 Then Exit Sub
If Target = Empty Then
Target.Comment.Delete
Else
If Target.Comment Is Nothing Then
Target.AddComment.Text Text:=CStr(Now())
Else
Target.Comment.Delete
Target.AddComment.Text Text:=CStr(Now())
End If
Target.Comment.Visible = False
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)