Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to set values to a range vertically

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default How to set values to a range vertically

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying formula vertically, to pick up horizontal cell values Jammings Excel Worksheet Functions 3 July 24th 09 03:10 PM
SUMPRODUCT or SUMIF if any values in a range equal any values in another range PCLIVE Excel Worksheet Functions 3 July 15th 09 07:43 PM
lookup values vertically in a list and return the repeats April_2004 Excel Worksheet Functions 1 November 13th 08 06:48 PM
copy values from vertically-horizontally vasileib7 Excel Programming 1 October 26th 07 01:36 AM
Array to Range assignments behave different going horizontally and vertically [email protected][_2_] Excel Programming 9 May 31st 07 06:35 PM


All times are GMT +1. The time now is 06:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"