Пример макроса: Проверка работы Dictionary

Исходный пример на VBA
Sub DictionaryTest()      ''e26
    Dim myDictionary As Object
    Dim k As Variant
    
    Set myDictionary = CreateObject("Scripting.Dictionary")
    myDictionary.Add 10, "Item1"
    myDictionary.Add 20, "Item2"
    myDictionary.Add 30, "Item3"
    Range("A1").Select
    For Each k In myDictionary.Keys()
        ActiveCell.value = k
        ActiveCell.Offset(0, 1).value = myDictionary(k)
        ActiveCell.Offset(1, 0).Select
    Next k
End Sub
JavaScript Р7
(function() {
    var oSheet = Api.GetActiveSheet();

    let myDictionary = {};
    myDictionary["10"] = "Item1";
    myDictionary["20"] = "Item2";
    myDictionary["30"] = "Item3";
    
    var oCell = oSheet.GetRange("A1");
    oCell.Select();
    for (var key in myDictionary){
        oCell.SetValue(key);
        oCell.SetOffset(0, 1);
        oCell.SetValue(myDictionary[key]);
        oCell.SetOffset(1, -1);
        oCell.Select();
    }       
})();
Поддержка слушателей курса
"Основы Java Script для Р7"