Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Transfering VBA Array Column Range to Excel Column Range

I know that I can make excel ranges = to other excel ranges if they have
the same dimensions. Assume ActiveColumn is a 100X1 (r,c) excel array.
Below I can make this range equal to an offset of itself


Range("ActiveColumn") = Range("ActiveColumn").Offset(0, 1).Value

But what happens if I want to make that range equal to a part of a VBA
array. Say the VBA Array is called DataArray. And also assume that
DataArray is 100x100. Is there any way I can make ActiveColumn = to a
portion of the array without using a Loop?


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Transfering VBA Array Column Range to Excel Column Range

A one way transfer, i.e., from the array to the XL range and if want to
pick the vector that corresponds to the outer index, the following will
work:

Range("A1").Resize(100, 1) = .Transpose(.Index(x, 1))

It transfers the first row of the 2D array x into 100 cells in column A
of the worksheet starting with A1.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , ExcelMonkey
says...
I know that I can make excel ranges = to other excel ranges if they have
the same dimensions. Assume ActiveColumn is a 100X1 (r,c) excel array.
Below I can make this range equal to an offset of itself


Range("ActiveColumn") = Range("ActiveColumn").Offset(0, 1).Value

But what happens if I want to make that range equal to a part of a VBA
array. Say the VBA Array is called DataArray. And also assume that
DataArray is 100x100. Is there any way I can make ActiveColumn = to a
portion of the array without using a Loop?


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Transfering VBA Array Column Range to Excel Column Range

You can't do it without executing loops; but if the functions in the
freely downloadable file at http://home.pacbell.net/beban are available
to your workbook, you can use the looping that is prewritten in the
those functions. For example, with 1 to 100 in Range("a1:a100"), the
following will transfer the elements of that range to the third "column"
of the array:

Sub testIt()
Dim rng As Range
Set rng = Range("A1:A100")
Dim arr() As Integer
ReDim arr(1 To 100, 1 To 100)
ReplaceSubArray arr, rng, 1, 3
End Sub

It replaces the portion of arr starting at "row" 1, "column" 3 with the
elements of rng.

Alan Beban



ExcelMonkey < wrote:
I know that I can make excel ranges = to other excel ranges if they have
the same dimensions. Assume ActiveColumn is a 100X1 (r,c) excel array.
Below I can make this range equal to an offset of itself


Range("ActiveColumn") = Range("ActiveColumn").Offset(0, 1).Value

But what happens if I want to make that range equal to a part of a VBA
array. Say the VBA Array is called DataArray. And also assume that
DataArray is 100x100. Is there any way I can make ActiveColumn = to a
portion of the array without using a Loop?


---
Message posted from http://www.ExcelForum.com/


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Transfering VBA Array Column Range to Excel Column Range

That won't work in Excel2000 and earlier for an x that is a 100x100
array, or any array of more than 5461 elements. And in any event, it
doesn't get at the OP's request for getting a range column into a VBA array.

Alan Beban

Tushar Mehta wrote:
A one way transfer, i.e., from the array to the XL range and if want to
pick the vector that corresponds to the outer index, the following will
work:

Range("A1").Resize(100, 1) = .Transpose(.Index(x, 1))

It transfers the first row of the 2D array x into 100 cells in column A
of the worksheet starting with A1.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Transfering VBA Array Column Range to Excel Column Range

The OP wrote, "Is there any way I can make ActiveColumn = to a portion
of the array without using a Loop?"
How does that translate to "it doesn't get at the OP's request for
getting a range column into a VBA array ?"

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
That won't work in Excel2000 and earlier for an x that is a 100x100
array, or any array of more than 5461 elements. And in any event, it
doesn't get at the OP's request for getting a range column into a VBA array.

Alan Beban

Tushar Mehta wrote:
A one way transfer, i.e., from the array to the XL range and if want to
pick the vector that corresponds to the outer index, the following will
work:

Range("A1").Resize(100, 1) = .Transpose(.Index(x, 1))

It transfers the first row of the 2D array x into 100 cells in column A
of the worksheet starting with A1.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Transfering VBA Array Column Range to Excel Column Range

Sorry; I guess I misinterpreted it (though I'm still not 100% sure). In
any event:

Range("A1").Resize(100, 1) = .Transpose(.Index(x, 1)) will fail in
Excel2000 and earlier if x contains more than 5461 elements; the Index
function won't accommodate it. It also, in Excel2000, returned an error
message that Index and Transpose were invalid or unqualified references.

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to the workbook, the
following will work in Excel2000 and earlier (it uses loops, but they
are prewritten into the RowVector function):

Range("A1").Resize(100, 1) = Application.Transpose(RowVector(x, 1))

Alan Beban

Tushar Mehta wrote:
The OP wrote, "Is there any way I can make ActiveColumn = to a portion
of the array without using a Loop?"
How does that translate to "it doesn't get at the OP's request for
getting a range column into a VBA array ?"


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
Lookup Value in Range/Array and Return Column Header Value [email protected] Excel Discussion (Misc queries) 3 June 16th 06 07:05 PM
Lookup Value in Range/Array and Return Column Header Value [email protected] Excel Worksheet Functions 3 June 16th 06 07:05 PM
EXCEL Sum column based on time range in different column? RD975 Excel Worksheet Functions 2 October 13th 05 05:19 PM
CountIf first column range = "Word" and second column range <> 0 TinaMo Excel Worksheet Functions 3 June 3rd 05 10:56 PM
Returning an array from a UDF to a column range Ron Davis Excel Programming 1 October 31st 03 01:12 AM


All times are GMT +1. The time now is 12:19 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"