|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Private Sub Worksheet_Change(ByVal Target As Range)
- Application.ScreenUpdating = False
- Dim ss
- If Target.Address(0, 0) <> "Y11" Then Exit Sub
- Application.EnableEvents = False
- Dim arr, ii, d2 As Object
- Set d2 = CreateObject("scripting.dictionary")
- arr = Sheet7.UsedRange.Value
- For ii = 2 To UBound(arr)
- ss = arr(ii, 1)
- If Len(ss) > 1 Then
- If Not d2.exists(ss) Then
- d2(ss) = Array(arr(ii, 20), arr(ii, 21), arr(ii, 22), arr(ii, 23), arr(ii, 24), arr(ii, 25), arr(ii, 26))
- End If
- End If
- Next
- br = [{"Y10","AD10","AI10","AN10","AS10","AX10","BC10"}]
- Dim ar, i, dic
- Set dic = CreateObject("scripting.dictionary")
- ar = [{"困气1","*0.8";"困气2","*0.6";"困气3","*0.4";"困气4","*0.2";"困气5","*0.1";"冲气1","/0.8";"冲气2","/0.6";"冲气3","/0.4";"冲气4","/0.2";"冲气5","/0.1"}]
- For i = 1 To UBound(ar)
- dic(ar(i, 1)) = ar(i, 2)
- Next
- tt = Sheet1.[BQ7].Value
- k = d2(tt)
- If Target.Value = "" Then
- For col = 0 To UBound(k)
- Sheet1.Range(br(col + 1)).Value = k(col)
- Next
- Else
- s = Sheet1.Range("y11").Value
- t = dic(s) '找出ar数组的系数
- For col = 0 To UBound(k)
- Sheet1.Range(br(col + 1)).Value = Evaluate(k(col) & t)
- Next
- End If
- Application.EnableEvents = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|