If you  want to know the column count of array you can use this

 

Sub ColumnCountofArray()
    Dim strArr()
    strArr = Range("A1:D10")
    MsgBox "Column of StrArr =" & UBound(strArr, 2)
End Sub

 

http://excelpoweruser.blogspot.in/2012/03/column-count-of-array.html

Rajan

 

 

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of tangledweb
Sent: Apr/Thu/2012 12:39
To: excel-macros@googlegroups.com
Subject: $$Excel-Macros$$ redim preserve seems to only allow columns
increase which is backwards

 

I want to use an array to store values as more efficient that doing it cell
by cell,

then copy the entire array into the sheet range when done.  But the size of
the

array not know initially.  I do know that number of columns, but not the
number 

of rows.   So I will have to do some redim preserve operations along the
way.

But redim preserve says you can only increase the outer value which is the
columns.

That makes no sense to me as you almost always need to increase the number
of

rows in a spreadsheet as new data is added.  So I think I must be missing
something.

I can define the array inverted switching the rows and columns although
clumsy to

work with but then copying it to the spreadsheet range as one assignment

sheetrange = myarray   will not work correctly.

What am I missing here?

-- 
FORUM RULES (986+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
 
----------------------------------------------------------------------------
--------------------------
To post to this group, send email to excel-macros@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to