在一行数据中,如何在非零值之后找到第一个零所在的列? Check this image for the example.
答案 0 :(得分:1)
答案 1 :(得分:0)
=FIND("0",TEXTJOIN(,,A2:E2),FIND("1",TEXTJOIN(,,A2:E2)))
编辑:
使用任何非零值:
=INDEX(OFFSET(A2,-(ROW()-1),MATCH(TRUE,INDEX(A2:E2<>0,),0),,COLUMNS(A2:E2)-MATCH(TRUE,INDEX(A2:E2<>0,),0)),1,MATCH(0,OFFSET(A2,0,MATCH(TRUE,INDEX(A2:E2<>0,),0),,COLUMNS(A2:E2)-MATCH(TRUE,INDEX(A2:E2<>0,),0)),0))
答案 2 :(得分:0)
Sub FindNonZero()
For i = 2 To 4
For j = 1 To 5
If Cells(i, j).Value <> 0 Then
For k = j To 5
If Cells(i, k).Value = 0 Then
Cells(i, 7).Value = "COL" & k
Exit For
End If
Next k
Exit For
End If
Next j
Next i
End Sub
答案 3 :(得分:0)
您可以在VBA中创建自己的功能
Function FindZero(TargetRange as range) As Long
Dim aCell as range
For each aCell in TargetRange
if aCell>0 AND aCell.Offset(0,1) = 0 then
FindZero = aCell.Offset(0,1).Column
Exit For
end if
next aCell
end function
然后在某个单元格中你只需要
=FindZero(A1:G1)
`
答案 4 :(得分:0)