- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
本帖最後由 GBKEE 於 2011-11-10 08:22 編輯
回復 6# Helain
請任意輸入 "aaaaaaa"
RMax_Row = Cells.Find("aa", , xlValues, xlPart).Row
RMax_Row = Cells.Find("aa", , xlFormulas, xlPart).Row 有找到:這兩程式碼沒錯誤
RMax_Row = Cells.Find("aa", , xlValues, xlWhole).Row
RMax_Row = Cells.Find("aa", , xlFormulas, xlWhole).Row 沒有找到:這兩程式碼會錯誤 陣列索引超出範圍
請不要用上面的語法 正確的寫法如下
expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)
Set R_Max = R_Profit.Find(What:=Rmax,LookIn:= xlFormulas,LookAt:= xlWhole)
Set R_Max = R_Profit.Find(LookIn:=xlFormulas, LookAt:=xlWhole, What:=Rmax)
全部有指明參數可任意放置參數的位置 但不可以 參雜著有指明參數 及沒指明的參數
Set R_Max = R_Profit.Find(Rmax, , xlValues, xlWhole)
Set R_Max = R_Profit.Find(Rmax, , xlFormulas, xlWhole)
如確定 先前的搜尋不是註解 LookIn:=xlComments 可用
Set R_Max = R_Profit.Find(Rmax, , , xlWhole)
If Not R_Max Is Nothing Then
R_MaxRow = R_Max.Row
R_Maxcolumn = R_Max.Column
End If |
|