Pergunta

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.

Foi útil?

Solução

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)]
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top