標(biāo)題: 用VBA自定義函數(shù)獲取最后非空單元格的行序 [打印本頁]

作者: xiaos    時間: 2015-4-3 23:21
標(biāo)題: 用VBA自定義函數(shù)獲取最后非空單元格的行序
獲取最后一非空單元格的行序或列序除了可以直接引用外還可以自定義函數(shù)來實現(xiàn):

Public Function End_Col(rag As Range) As Integer'自定義函數(shù)獲取最后非空單元格的行序-
'ActiveCell.Row-
Dim aa As Integer-
-
For Each temp In rag-
If temp.Value <> "" Then-
    aa = temp.Row'獲取行序-
    'aa=temp.column'獲取列序-
End If-
Next temp-
End_Col = aa-
End Function-
-
示例:-
只有B23非空,則End_Col(A2:B100)=23-






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1