这要用 VBA,
Excel 内Alt+F11, 视图---代码窗口, 把如下代码复制进去,
Alt+F11退出, 选中 需要统计的单元格, Alt+F8 运行 这个程序,
如果实际你要 批量处理, 可以 [email protected]
如下以一个单元格为例子:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/38dbb6fd5266d016a2eb840a942bd40735fa3525?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
Sub FindPrecedents()
' written by Bill Manville
' With edits from PaulS
' this procedure finds the cells which are the direct precedents of the active cell
Dim rLast As Range, iLinkNum As Integer, iArrowNum As Integer
Dim stMsg As String
Dim bNewArrow As Boolean
Application.ScreenUpdating = False
ActiveCell.ShowPrecedents
Set rLast = ActiveCell
iArrowNum = 1
iLinkNum = 1
bNewArrow = True
Do
Do
Application.Goto rLast
On Error Resume Next
ActiveCell.NavigateArrow TowardPrecedent:=True, ArrowNumber:=iArrowNum, LinkNumber:=iLinkNum
If Err.Number > 0 Then Exit Do
On Error GoTo 0
If rLast.Address(external:=True) = ActiveCell.Address(external:=True) Then Exit Do
bNewArrow = False
If rLast.Worksheet.Parent.Name = ActiveCell.Worksheet.Parent.Name Then
If rLast.Worksheet.Name = ActiveCell.Parent.Name Then
' local
stMsg = stMsg & vbNewLine & Selection.Address
stcount = stcount + Selection.Cells.Count
Else
stMsg = stMsg & vbNewLine & "'" & Selection.Parent.Name & "'!" & Selection.Address
stcount = stcount + Selection.Cells.Count
End If
Else
' external
stMsg = stMsg & vbNewLine & Selection.Address(external:=True)
End If
iLinkNum = iLinkNum + 1 ' try another link
Loop
If bNewArrow Then Exit Do
iLinkNum = 1
bNewArrow = True
iArrowNum = iArrowNum + 1 'try another arrow
Loop
rLast.Parent.ClearArrows
Application.Goto rLast
MsgBox "引用范围个数为" & stcount
MsgBox "Precedents are" & stMsg
Exit Sub
End Sub
追问我给你发过去一个表,请你帮我看一下。其实我是想直接从一个求和函数中得到我它的求和单元格个数。
追答这就是求 引用的单元格个数啊, 你没看到图片么
追问能不能在我给你发过去的表格里做一下,越简单越好。
追答发啊, 不是已经写了 怎么发么
追问我把我求解的表格发你youxian里了
追答已回复
追问B10中的“6”怎么不见公式呢?
追答你对公式情有独钟 还是怎么的,
为什么要用公式?
用公式也可以,没研究过,
点一下就实现了, 你还纠结, 原表又不肯发, 自己又想用个例子就倒腾出来,。。。。。。。。。。 无语
追问你没明白,也没理解我。
追答我又不 基,理解你干嘛,
好吧,我理解你,再发你份用公式的