Re: Set up array to write to table?
- From: "Jay Freedman" <jay.freedman@xxxxxxxxxxx>
- Date: Tue, 4 Apr 2006 14:04:51 -0400
Hi Ed,
Sorry to pop your bubble, although it will save you some work...
You *can* use ReDim Preserve with a multidimensional array. It's just that
you're restricted to changing the number representing the *last* dimension.
For a two-dimensional array MyArray(x,y), you can change y but you can't
change x. In other words, you can make more rows but you can't change the
number of columns in the table. This is explained pretty well by the VBA
help topic on the ReDim statement.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Ed wrote:
It *is* that simple! I better go back and reread that section on
arrays! Thank you, Jonathan.
One more thing I think I _did_ understand - I've used ReDim Preserve
with a single dimension to add another value to the array while
writing to it, but you can't use Preserve with a multidimensional
array, correct? So I would need to declare this with more than the
paces I will need, then ReDim (if I want to) to match the actual
number of values assigned?
Ed
"Jonathan West" <jwest@xxxxxxxx> wrote in message
news:eDtf8nAWGHA.5808@xxxxxxxxxxxxxxxxxxxxxxx
Hi Ed,
try this
For y = 1 to 4
For x = 1 to 10
Table.Cell(x, y).Range.Text= MyArray(x, y)
Next x
Next y
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition
www.classicvb.org
"Ed" <ed_millis@xxxxxxxxxxxxxxxxx> wrote in message
news:OiO9PfAWGHA.4960@xxxxxxxxxxxxxxxxxxxxxxx
I haven't worked much with arrays, so please forgive me if this is
a basic question. I want to collect a series of text elements to
write into a table all in one go, rather than write to the table
one by one as collected. If I only had a one column table, I would
just say For x = 1 to 10
Table.Cell(x, 1).Text = Array(x)
Next x
But when I've got four columns, how do I say
Table.Cell(x, y).Text = Array(x,y) ??
(I figure that's not the correct way to do it - but it was the
closest I could come to explaining it.)
Any help is appreciated.
Ed
.
- References:
- Set up array to write to table?
- From: Ed
- Re: Set up array to write to table?
- From: Jonathan West
- Re: Set up array to write to table?
- From: Ed
- Set up array to write to table?
- Prev by Date: Re: Set up array to write to table?
- Next by Date: Re: Conditional fields on a word document
- Previous by thread: Re: Set up array to write to table?
- Next by thread: Re: Set up array to write to table?
- Index(es):
Relevant Pages
|