[英]Using Match and Index functions in excel VBA
我正在嘗試使用VBA在光度報告中查找值(列和行標簽的數字角度值以及數組中的數字值)。 我正在嘗試使用match函數和index函數。 但是,在我的UDF中,在工作表中工作的代碼會自動返回#VALUE錯誤。
Dim H_10 As Double
Dim V_5 As Double
Dim hangle As Double
Dim vangle As Double
H_10 = WorksheetFunction.MRound(h, 10)
V_5 = WorksheetFunction.MRound(v, 5)
' rounds off angle values to match row and collumn headers
hangle = Application.WorksheetFunction.Match(H_10, "B42:T42", 0)
vangle = Application.WorksheetFunction.Match(V_5, "A43:A79", 0)
'looks up the row/column index
cd = Application.Index("B43:T79", hangle, vangle, 0)
' uses row and column index to find value in array
我最初在index函數中具有match函數,但是將它們拉出來進行故障排除。
我已經嘗試過簡單地將我知道會存在的數字放在索引函數中,但是無論何時它或匹配項處於活動狀態,我都會全面遇到#VALUE錯誤。
WorksheetFunctions
需要使用范圍對象而不是范圍字符串。 將范圍字符串更改為: Range("RangeString")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.