如下图例子(查找区域为A2:A10):
公式为=ADDRESS(MIN(IF(A2:A10<>"",ROW(2:10))),1,4),数组公式,三键结束。
返回结果为“A4”,单元格A4是查找区域内第一个非空单元格地址。
如果是要返回第一个费空单元格内容,公式为=INDEX(A:A,MIN(IF(A2:A10<>"",ROW(2:10))))
如图,假如数据在第一行,在A2中输入
=MATCH(LOOKUP(1,0/(A1:Z1<>""),1:1),1:1,)
借别人一句代码:查找同行最后一个非空单元格
[a5] = Range("a1:n1").Find("*", , , , 1, 2).Column
-------------------------------------------------
Sub kk()
Dim i, j As Integer
For i = 1 To Range("A65536").End(xlUp).Row()
If Cells(i, 1) = "科学" Then
j = Range("a" & i & ":" & "iv" & i).Find("*", , , , 1, 2).Column
Cells(i, 2) = Cells(i, j)
End If
Next i
End Sub
Sub 填充()
For i = 2 To Range("A65536").End(xlUp).Row()
If Cells(i, 1) = "科学" Then
Cells(i, 2) = Cells(i, 1).Offset(, Cells(i, 256).End(xlToLeft).Column() - 1)
End If
Next
End Sub
代码,假设了你的第一行是标题行。
代码是根据excel2003来写的。
如果你的列数据不超过256,2007也可以用。
Sub 提取()
Dim i As Integer
Dim j As Integer
For i = 1 To 10000 Step 1
If Cells(i, 1) = "" And Cells(i + 1, 1) = "" And Cells(i + 2, 1) = "" _
And Cells(i + 3, 1) = "" And Cells(i + 4, 1) = "" And Cells(i + 5, 1) = "" Then Exit For
For j = 256 To 1 Step -1
If Cells(i, 1) = "科学" Then
If Cells(i, j) <> "" Then
If Cells(i, 2) <> Cells(i, j) Then
Cells(i, 2) = Cells(i, j)
End If
Exit For
End If
End If
Next j
Next i
End Sub