Create One-Dimensional Array from Two-Dimensional Array

S

Stratuser

I need to create a one-dimensional array from a two-dimensional array. My
two-dimensional array has R * C (rows times columns) elements. I want my
one-dimensional array to have all the data from the two-dimensional array,
except for the last column, so it needs to have R * (C-1) elements.

Any ideas about how to construct this one-dimensional array?
 
T

Tom Ogilvy

Dim varr1()
num = (ubound(varr,1) - lbound(varr,1) + 1) * _
(ubound(varr,2) - lbound(varr,2))

redim varr1(1 to num)
for i = lbound(varr,1) to ubound(varr,1)
for j = lbound(varr,2) to ubound(varr,2) - 1
k = k + 1
varr1(k) = varr(i,j)
next
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top