Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am writing a C# program that interacts with Excel. When I have a range in Excel that contains a few "horizontal" cells (e.g. "A1" to "D1"), I can fill the range with values from an array: Microsoft.Office.Interop.Excel.Range rangeSeries = wsData.get_Range("A1", "D1"); range.set_Value(missing, array); But when I try to do the same thing, but with a range with vertical cells, all the cells in the range get the value of the first array field. Anyone knows how this can be done? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I can't answer about C# but in VBA you need to dimension the array as Row X
Column to fit your range horizontally or vertically. Here's an example (I always use 1-based arrays) Option Base 1 Sub test() Dim a1(1, 4) Dim a2(4, 1) a1(1, 1) = "A" a1(1, 2) = "B" a1(1, 3) = "C" a1(1, 4) = "D" a2(1, 1) = "E" a2(2, 1) = "F" a2(3, 1) = "G" a2(4, 1) = "H" Range("a1:d1") = a1 Range("a2:a5") = a2 End Sub "-kve-" wrote: Hi, I am writing a C# program that interacts with Excel. When I have a range in Excel that contains a few "horizontal" cells (e.g. "A1" to "D1"), I can fill the range with values from an array: Microsoft.Office.Interop.Excel.Range rangeSeries = wsData.get_Range("A1", "D1"); range.set_Value(missing, array); But when I try to do the same thing, but with a range with vertical cells, all the cells in the range get the value of the first array field. Anyone knows how this can be done? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copying formula vertically, to pick up horizontal cell values | Excel Worksheet Functions | |||
SUMPRODUCT or SUMIF if any values in a range equal any values in another range | Excel Worksheet Functions | |||
lookup values vertically in a list and return the repeats | Excel Worksheet Functions | |||
copy values from vertically-horizontally | Excel Programming | |||
Array to Range assignments behave different going horizontally and vertically | Excel Programming |