返回列表 上一主題 發帖

[發問] 關於 Find用法

抱歉, 我QrF還是讀不到資料ㄝ

Sub test_3()

Dim R_Profit As Range        'R's 2nd profit table
Dim M_Profit As Range        'M's 2nd profit table
Dim M_MaxProfit As Range     'For different Qr, M's Max profit

Set R_Profit = Range(Cells(20, 2), Cells(30, 12))
Set M_Profit = Range(Cells(2, 2), Cells(12, 12))
Set M_MaxProfit = Range(Cells(15, 2), Cells(15, 12))

Set QrF = R_Profit.Find(Application.Max(R_Profit), , , xlWhole)

    If Not QrF Is Nothing Then
   
        A = QrF.Row
        B = QrF.Column
        
    End If
   

End Sub

TOP

本帖最後由 GBKEE 於 2011-11-10 15:16 編輯

回復 11# Helain
Find 搜尋的條件如果沒重新設定 會依照上次的搜尋條件來尋找的
Set QrF = R_Profit.Find(Application.Max(R_Profit), , , xlWhole)    這語法沒指定是 (公式 內容 註解)  有指定儲存格的內容需完全相同

請查看7樓 Hsieh超版的圖片, 查查看  你 Excel上次的搜尋條件是 (公式 內容 註解).

TOP

回復 12# GBKEE



Find 搜尋的條件會依照上次的搜尋條件來尋找的 (我不懂這句話的意思)

Set QrF = R_Profit.Find(Application.Max(R_Profit), ,xlvalues , xlWhole)

QrF還是讀不到東西

TOP

本帖最後由 GBKEE 於 2011-11-10 15:26 編輯

回復 13# Helain
Find 搜尋的條件如果沒重新設定 會依照上次的搜尋條件來尋找的
Set QrF = R_Profit.Find(a, , xlFormulas, xlWhole)
你尋找的是數字 與 工作表上顯示出的的文字(數字)不一樣
  1. Sub test_3()
  2. Dim R_Profit As Range        'R's 2nd profit table
  3. Dim M_Profit As Range        'M's 2nd profit table
  4. Dim M_MaxProfit As Range     'For different Qr, M's Max profit
  5. Set R_Profit = Range(Cells(20, 2), Cells(30, 12))
  6. Set M_Profit = Range(Cells(2, 2), Cells(12, 12))
  7. Set M_MaxProfit = Range(Cells(15, 2), Cells(15, 12))
  8. MsgBox Application.Max(R_Profit)
  9. Set QrF = R_Profit.Find(Application.Max(R_Profit), , xlFormulas, xlWhole)
  10. MsgBox QrF.Text
  11.     If Not QrF Is Nothing Then
  12.         R = QrF.row
  13.         C = QrF.column
  14.     End If
  15. End Sub
複製代碼

TOP

謝謝大大,
所以 XlFormulas 是Find.尋找指range裡面的值包含公試
也就是說 如果range裡的值是經由運算得到的 就要用xlformulas??

那 如果說 range 裡面的值剛好有數個相同的, 那find 可以讀嗎?是隨便讀取其中一個?

另外, 哪邊有VBA所有函數, 以及說明呢?

TOP

回復 15# Helain
如果說 range 裡面的值剛好有數個相同的, 那find 可以讀嗎?是隨便讀取其中一個?
自己寫寫 試試看.

另外, 哪邊有VBA所有函數, 以及說明呢?
VBA 指令說明 從中的範例 去一一體會

TOP

找整個數字(5.55)的方法:
   Set b = profit.Find(5.55, , xlValues, xlWhole)
找以5.55"為首" 的方法 (如5.55, 5.55001, 5.552,5.55999....)
   Set b = profit.Find(5.55, , xlValues, xlpart)
(與這個一樣    Set b = profit.Find(5.55, , xlValues)

留意excel是以"文字"的方式找, 不是以數字大少來找, 這樣的話還要將5.55以冒號括起來嗎"5.55"

TOP

回復 5# GBKEE


    http://forum.twbts.com/thread-9780-1-1.html G大可以幫我一下嗎??

TOP

        靜思自在 : 成功是優點的發揮,失敗是缺點的累積。
返回列表 上一主題