您好我有一個用於價格txtBox(txtPrice)的Userform上的2個ListBox的(Purchase_Select_Debtor)&(Purchase_Select_Quantity)。需要幫助使用動態命名範圍的INDEX和MATCH
該規範使用索引和匹配返回基於債務人和數量選擇的結果。
下面是我目前的代碼工作正常,但每次我添加一個新的債務人,我不得不改變代碼來改變物理範圍。
我想使用動態命名範圍進行設置,因此當我添加新的債務人時,索引/匹配函數仍然會返回結果。
Temp = Application.Index(Sheets("Price_list").Range("A1:I22"), _
Application.Match(Purchase_Select_Debtor.Value, Sheets("Price_list").Range("A1:A22"), 0), _
Application.Match(Purchase_Select_Quantity.Value, Sheets("Price_list").Range("A1:I1"), 0))
txtPrice.Value = FormatCurrency(Expression:=Temp, _
NumDigitsAfterDecimal:=2)
我試過這個,但它沒有工作;類型錯配運行時錯誤13
Temp = Application.Index(Range("Price_list_Table"), _
Application.Match(Purchase_Select_Debtor.Value, Range("Price_list_Debtor_ADD"), 0), _
Application.Match(Purchase_Select_Quantity.Value, Range("Price_list_Quantity_ADD"), 0))
txtPrice.Value = FormatCurrency(Expression:=Temp, _
NumDigitsAfterDecimal:=2)
調試器突出顯示了這兩行代碼;
txtPrice.Value = FormatCurrency(Expression:=Temp, _
NumDigitsAfterDecimal:=2)
溫度的值= 「」
它使用作爲refrence下圖是本;
http://i19.photobucket.com/albums/b152/mantricorb/Chart.jpg
和動態命名區域是如下;
Price_list_Table = OFFSET(PRICE_LIST $ A $ 1,0,0,COUNTA(PRICE_LIST $ A:!$ A),9)!
Price_list_Debtor_ADD = OFFSET(PRICE_LIST $ A $ 1,0,0 ,COUNTA(PRICE_LIST $ A:$ A),1)
Price_list_Quantity_ADD = OFFSET(PRICE_LIST $ A $ 1:$ I $ 1,0,0)
我認爲有一些錯誤與動態命名範圍,因爲它不返回結果,任何幫助將非常感激。