|
楼主 |
发表于 2017-8-26 09:45
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
謝謝sqrall900的回覆,請試試看如何偵測下列代碼的兩個For循環的4及1。謝謝。
Sub 將二維JSON數組寫入單元格()
Dim JsStr As String
Dim Js As String
Dim i As Integer
Dim j As Integer
JsStr = "{""data3"":[[""1"",""A""],[""2"",""B""],[""3"",""C""],[""4"",""D""],[""5"",""E""]]}"
'撰寫JAVA函數
Js = "function j(s,i,j){return eval('(' + s + ').data3[' + i + '][' + j + ']');}"
With CreateObject("MSScriptControl.ScriptControl")
.Language = "JScript"
.AddCode Js
For i = 0 To 4
For j = 0 To 1
Cells(i + 1, j + 1) = .Run("j", JsStr, i, j)
Next j
Next i
End With
End Sub |
|