Fail to pass value to IReadRangeRef by variable

There’re two variables as below
ok_dict = new Dictionary(of Int32, String)() From {{1,“”“A1:A100"”“},{2,”““B1:B10"””},{3,“”“C1:C100"”"}}
ok_key = 2

When I using “Copy/Paste range” activity with Source option as below, it throws an error as “range B1:B10 does not exist”
Excel.Sheet(“Sheet2”).Range(ok_dict(ok_key))

However, when I directly using Source option as Excel.Sheet(“Sheet2”).Range(“B1:B10”), it works.

But I need a dictionary variable to pass the value, can anyone help on this? thanks!!!

It’s the quotes.

You add this value to your dictionary: “A1:A100”. Noted as a string this is “”““A1:A100"””.
However, .range input is a string containing only the range without the quotes. The literal version that you have working only hads the outer quotes for string notation.

This should work:
ok_dict = new Dictionary(of Int32, String)() From {{1,"A1:A100"},{2,"B1:B10"},{3,"C1:C100"}}
ok_key = 2
Excel.Sheet("Sheet2").Range(ok_dict(ok_key))

@Symos,

No need to pass Ranges like this “”““A1:B4"””. Only string is fine. Sample

Thanks,
Ashok :slight_smile: