表白:黑白圣堂血天使,天劍鬼刀阿修羅。 講解對(duì)象:/VBA 查找某個(gè)表某列 最后一個(gè)數(shù)字 作者:融水公子 rsgz
VBA 不是很熟悉 但也還是完成了自己的目的 下面的代碼實(shí)現(xiàn)了 VBA 查找某個(gè)表某列 最后一個(gè)數(shù)字Sub mycode()
Dim valuee As Integer
Dim biaoo As Integer
Dim strr As String
biaoo = 20
strr = "出口國(guó)家"
'value (biao)
Debug.Print value(strr, biaoo)
End Sub
' 關(guān)鍵詞 的最后一個(gè)數(shù)
Function value(str As String, biao As Integer)
Dim liee As Integer
Dim hangg As Integer
liee = lie(str, biao): Debug.Print liee & "列"
' 那一列最后一個(gè)數(shù) 的行數(shù)
hangg = Worksheets(biao).Cells(65536, liee).End(xlUp).Row: Debug.Print hangg & "行"
value = Worksheets(biao).Cells.Item(hangg, liee)
' value = Worksheets(biao).hangg.value
End Function
' 查找關(guān)鍵詞在哪一列
Function lie(str As String, biao As Integer) As Long
'biao = 3
'str = "數(shù)量"
For Each Rng In Worksheets(biao).Range("A1:AA200")
If Rng = str Then
a = Rng.Row
b = Rng.Column
End If
Next Rng
Key = Worksheets(biao).Cells(a, b)
Debug.Print "表" & Worksheets(biao).Name & ":" & Key & "-->" & "(" & a & ":" & b & ")"
lie = b
End Function 這是運(yùn)行結(jié)果:
 === 公眾號(hào):不浪仙人 謝謝大家的支持!可以點(diǎn)擊我的頭像,進(jìn)入我的空間瀏覽更多文章呢。建議大家360doc[www.hbhlny.cn]注冊(cè)一個(gè)賬號(hào)登錄,里面真的有很多優(yōu)秀的文章,歡迎大家的到來(lái)。 ---
|