LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Strange pasting array to cells behavior

First off, if you know an easier way to fill a 1-D array with a 1-D range's
values, then add to it from another 1-D range, please let me know. Someone
posted that ArrayName = Range("A1:A5") would put those 5 values in the
array, but it was not working for me. What I'm doing is assigning specified
range of cell's values to an array, then assigning another specified range'
values to it aftr a little more operation. My problem is with my first
assignment, however:

I have this:

dim ElementList() as variant

StartRange = Range(FoundIt.Address).Offset(3, -2).Address
EndRange = Range(StartRange).End(xlDown).Address

I've already done some variable assignments, you can trust that these ranges
being assigned is working; StartRange is A8, EndRange is A11

I then populate ElementList array with the values of the cells From A8 to
A11:

For Each Cell In Range(StartRange, EndRange)
ReDim Preserve ElementList(0 To i)
ElementList(i) = Cell.Value
i = i + 1
Next Cell

Now, as I'm looping through the cells in this range, I can debug.print each
value; so the array is indeed getting all the cell values. HOWEVER, when I
then execute this line:

Worksheets("Sheet1").Range("C3:C" & UBound(ElementList) + 1) =
Application.WorksheetFunction.Transpose(ElementLis t)

I only get 2 of the items in the array. When I change the "+1" to "+3" I
get all of them. Why would my range that I'm filling with my array have to
be 3 cells bigger than the number of values in my array in order to get all
the values? There are no blanks in the array, when I try to debug.print(4)
I get subscript out of range, because there are only 0 through 3 items in
there.

Can anyone explain why this is happening? And please, remember, if there's
an easier way to assemble an array with a range's cell values and then
output it to a column, I'm all ears. Big time.

Thanks for reading



 
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
Strange behavior when calculate two or more cells Gribs Excel Worksheet Functions 2 November 21st 08 07:43 PM
Need Help: Strange, Strange Behavior ( Not Me. My Model! ) SteveM Excel Programming 2 December 16th 07 06:02 PM
PERCENTRANK in array formula: strange behavior vezerid Excel Discussion (Misc queries) 4 March 9th 06 04:11 PM
Strange behavior in INDEX(..., MIN(...)) - array formula vezerid Excel Discussion (Misc queries) 2 February 21st 06 11:56 AM
Strange behavior. Wiley Coyote Excel Discussion (Misc queries) 7 October 18th 05 04:35 PM


All times are GMT +1. The time now is 03:11 AM.

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"