源数据采用以下格式
A B
1 0
2 0
4 1
5 0
6 0
8 1
我原本打算列出A栏中缺少的项目,但由于这对我来说不太合适,我打算通过我现在提出的方法实现同样的目的。
我想要的是一个列表
C
3
7
基本上通过使用B列中提供的值给出了缺失的序列号。但基本上任何能给我C列下列出的值的解决方案都将非常受欢迎。
应该注意的是,我正在处理一个大型列表,因此不宜进行手动过滤等。
答案 0 :(得分:0)
在单元格 G4 中输入您要查看的地址,例如 A2:A5 ,然后使用下面的数组公式。唯一的假设是数字列表应从 1 开始。我知道它看起来很疯狂,配方。此公式必须应用于范围,因此选择一个范围,然后转到地址栏粘贴此公式并按 CTRL + SHIFT + ENTER 。在这种特殊情况下,范围必须是柱形。
我将公式保留为未格式化的文本,因此复制起来更容易。
= IF(INT(SQRT(MMULT((IF(移调(MMULT(INDIRECT(G4),1 + 0 * TRANSPOSE(ROW(INDIRECT(" 1:"&安培; MAX(INDIRECT( G4)))))))= MMULT(ROW(INDIRECT(" 1:"&安培; MAX(INDIRECT(G4)))),1 + 0 * TRANSPOSE(ROW(INDIRECT(&#34 1:"&安培; COUNTA(INDIRECT(G4)))))),0,ROW(INDIRECT(" 1:"&安培; MAX(INDIRECT(G4)))))^ 2),1个+ 0 * ROW(INDIRECT(" 1:"&安培; COUNTA(INDIRECT(G4)))))/ COUNTA(INDIRECT(G4))))= SQRT(MMULT((IF (移调(MMULT(INDIRECT(G4),1 + 0 * TRANSPOSE(ROW(INDIRECT(" 1:"&安培; MAX(INDIRECT(G4)))))))= MMULT(ROW(INDIRECT (" 1:"&安培; MAX(INDIRECT(G4)))),1 + 0 * TRANSPOSE(ROW(INDIRECT(" 1:"&安培; COUNTA(INDIRECT(G4 )))))),0,ROW(INDIRECT(" 1:"&安培; MAX(INDIRECT(G4)))))^ 2),1个+ 0 * ROW(INDIRECT(&#34 1:"&安培; COUNTA(INDIRECT(G4)))))/ COUNTA(INDIRECT(G4))),SQRT(MMULT((IF(移调(MMULT(INDIRECT(G4),1 + 0 * TRANSPOSE (ROW(INDIRECT(" 1:"&安培; MAX(INDIRECT(G4)))))))= MMULT(ROW(INDIRECT(" 1:"&安培; MAX( INDIRECT(G4)))),1 + 0 * TRANSPOSE(ROW(INDIRECT(" 1:"&安培; COUNTA(INDIRECT(G4)))))),0,ROW(IN DIRECT(" 1:"&安培; MAX(INDIRECT(G4)))))^ 2),1 + 0 * ROW(INDIRECT(" 1:"&安培; COUNTA( INDIRECT(G4)))))/ COUNTA(INDIRECT(G4))),"&#34)
公式可以理解为
=IF(INT(A)=A,A, "")
其中A是
SQRT(MMULT((IF(TRANSPOSE(MMULT(INDIRECT(G4),1+0*TRANSPOSE(ROW(INDIRECT("1:"&MAX(INDIRECT(G4)))))))=MMULT(ROW(INDIRECT("1:"&MAX(INDIRECT(G4)))),1+0*TRANSPOSE(ROW(INDIRECT("1:"&COUNTA(INDIRECT(G4)))))),0,ROW(INDIRECT("1:"&MAX(INDIRECT(G4)))))^2),1+0*ROW(INDIRECT("1:"&COUNTA(INDIRECT(G4)))))/COUNTA(INDIRECT(G4)))
答案 1 :(得分:0)
如果不需要列B
(可以从A
计算),假设您有名为worksheet1
的工作表上的数据,则写入所有缺失值的VBA子列C
如下:
Sub worksheet1c()
'this contains the position in column A
Dim i As Integer
'this contains the position in column C
Dim j As Integer
'the numbers from 1
Dim number As Integer
'initialization
i = 1
j = 1
number = 1
'check all numbers in column A from row 2
Do While Sheets("worksheet1").Cells(i, 1).Value <> ""
'if there is a difference between number and the value in cell write them to column C
Do Until number = Sheets("worksheet1").Cells(i, 1).Value
Sheets("worksheet1").Cells(j, 3).Value = number
j = j + 1
number = number + 1
Loop
i = i + 1
number = number + 1
Loop
End Sub