Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default arrays again

Static Runner() As Variant

idex = idex + 1
A = 13
For I = 1 To 4

A = A + 1
ReDim Preserve Runner(1 To 4, 1 To idex)
Runner(I, idex) = Range("f" & A)
Debug.Print Runner(I, idex)

Next I

Range("t2").Resize(UBound(Runner, 1), 4) =
Application.Transpose(Runner)
Hi, could somebody what Im doing wrong with above. Ive got runner as a
static variable, Im using this in worksheet change so each cell change
idex counts up. Im adding data to runner then transposing to a range
purly to test data is going in ok, wont be doing this in final macro.
When I transpose I only get 4 rows and 4 columns, if I change the 4 to
say 10 then I get 10 cols 6 with n/a in which is what i thought would
happen. I thought i would have had to put the redim as (1 to idex, 1 to
4), but this creates an error. if I increase the the redim (1 to 50, 1
to idex) i get 50 rows, but this doesnt help because anything added
after 50 doesnt show. Any Ideas on what im doing wrong.
Regards Robert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default arrays again

The upperbound of dimension1 is 4 but you want to use the upperbound of
dimension 2 in your transpose assignment. Also, don't redim inside your loop
since there is nothing changing inside the loop that would require a redim.

idex = idex + 1
ReDim Preserve Runner(1 To 4, 1 To idex)
A = 13
For I = 1 To 4
A = A + 1
Runner(I, idex) = Range("f" & A)
Debug.Print Runner(I, idex)
Next I

Range("t2").Resize(UBound(Runner, 2), 4) = _
Application.Transpose(Runner)

--
Regards,
Tom Ogilvy

" wrote:

Static Runner() As Variant

idex = idex + 1
A = 13
For I = 1 To 4

A = A + 1
ReDim Preserve Runner(1 To 4, 1 To idex)
Runner(I, idex) = Range("f" & A)
Debug.Print Runner(I, idex)

Next I

Range("t2").Resize(UBound(Runner, 1), 4) =
Application.Transpose(Runner)
Hi, could somebody what Im doing wrong with above. Ive got runner as a
static variable, Im using this in worksheet change so each cell change
idex counts up. Im adding data to runner then transposing to a range
purly to test data is going in ok, wont be doing this in final macro.
When I transpose I only get 4 rows and 4 columns, if I change the 4 to
say 10 then I get 10 cols 6 with n/a in which is what i thought would
happen. I thought i would have had to put the redim as (1 to idex, 1 to
4), but this creates an error. if I increase the the redim (1 to 50, 1
to idex) i get 50 rows, but this doesnt help because anything added
after 50 doesnt show. Any Ideas on what im doing wrong.
Regards Robert


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default arrays again

Thankyou Tom. Thats sorted it perfect. Im slowly getting to grips with
these arrays.
Regards Robert

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
Two arrays same? FARAZ QURESHI Excel Discussion (Misc queries) 4 April 23rd 09 12:22 AM
Need help with arrays (I think) rbhedal Excel Worksheet Functions 3 October 19th 05 07:24 AM
About Arrays hke[_23_] Excel Programming 2 November 17th 04 01:29 PM
using arrays in vba JulieD Excel Programming 4 August 12th 04 04:59 PM
Arrays JAmes L Excel Programming 3 April 21st 04 11:00 AM


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