‘js
‘只对本表有效!
- Sub js_kao()
- Dim s$, s1
- Dim ar, br
- Dim i%, j%, k%
- Dim y As Object
- Dim d As Object
- Dim js As Object
- Set js = CreateObject("ScriptControl")
- Set d = CreateObject("Scripting.Dictionary")
- js.Language = "JScript"
- ar = [a1].CurrentRegion
- br = [f1].CurrentRegion
- '---------------------------------------
- For i = 2 To UBound(ar)
- If Not d.exists(ar(i, 1)) Then
- k = 0
- d(ar(i, 1)) = ""
- tt = ar(i, 1)
- s = "var " & ar(i, 1) & "=[];"
- js.addcode s
- End If
- s = tt & "[" & k & "]=""" & ar(i, 2) & "," & ar(i, 3) & ",'" & ar(i, 4) & "'"";"
- js.addcode s
- k = k + 1
- Next
- '---------------------------------------
- For i = 2 To UBound(br)
- For j = 1 To Len(br(i, 1))
- If IsNumeric(Mid(br(i, 1), j, 1)) Then Exit For
- Next j
- s = Left(br(i, 1), j - 1)
- s1 = Val(Mid(br(i, 1), j))
- Set y = js.eval(s)
- For Each x In y
- If s1 >= Val(Split(x, ",")(0)) And s1 <= Val(Split(x, ",")(1)) Then
- br(i, 2) = Replace(Split(x, ",")(2), "'", "")
- Exit For
- End If
- Next
- Next i
- [f1].CurrentRegion = br
- MsgBox "job is okey!"
- End Sub
复制代码
|