|
楼主 |
发表于 2023-3-20 08:23
|
显示全部楼层
本帖最后由 rayhen 于 2023-3-20 09:09 编辑
谢谢版主 liulang0808 这里只是简单的,如果很多张怎么解
如果一张一张可以这样做 公式\错误检查\循环引用
formulas\error checking\circular references
此代码没有反应
- Sub FindCircularReferences()
- Dim ws As Worksheet
- Dim rng As Range
- Dim cell As Range
- Dim circulars As Variant
- Dim msg As String
-
- Application.ScreenUpdating = False
-
- For Each ws In ThisWorkbook.Worksheets
- Set rng = ws.Cells.SpecialCells(xlCellTypeFormulas)
-
- On Error Resume Next
- circulars = rng.CircularReference
- On Error GoTo 0
-
- If Not IsEmpty(circulars) Then
- msg = "Circular reference(s) found on sheet " & ws.Name & ":" & vbCrLf & vbCrLf
- For Each cell In circulars
- msg = msg & "Cell " & cell.Address(False, False) & vbCrLf
- Next cell
- MsgBox msg, vbCritical, "Circular Reference Found"
- End If
- Next ws
-
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|