在 excel 中使用 alt + f11 把 vba 界面打開,然後添加模塊,在模塊中寫自己定義的函數
示例代碼
Function normalize(current, r As range)
max = 0
min = 1000
For Each b In r
If b.Value > max Then max = b.Value
If b.Value < min Then min = b.Value
Next
normalize = (current - min) / (max - min)
End Function
在單元格里可以直接調用
= normalize(D2,D$2:D$10)