I am trying to concatenate two columns in Excel 2010 using DataNitro, but whenever I try to run this command,

CellRange("C1:C5").value = CellRange("A1:A5").value + CellRange("B1:B5").value

I get this error in the DataNitro Python Shell - "CellRange set to object of wrong length"

I am trying to concatenate values in columns A and B into column C.

有帮助吗?

解决方案

CellRange("A1:A5").value + CellRange("B1:B5").value

Will add together two lists of length 5 to give you a list of length 10. To concatenate the elements in the lists, you should do:

CellRange("C1:C5").value = [x + y for x, y in zip(CellRange("A1:A5").value, CellRange("B1:B5").value)]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top