Re: Array and resize
- From: "Bob Phillips" <bob.phillips@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 31 May 2005 16:22:37 +0100
Is there a question there?
--
HTH
RP
(remove nothere from the email address if mailing direct)
"CoRrRan" <"CoRrRan~~[at]~~gmail~~[dot]~~com"> wrote in message
news:11dh375iiqh3$.1mrxksfnd6u2w$.dlg@xxxxxxxxxxxxx
> Thanks for the reply Bob,
>
> OK, so using the array function as I did can only be done with a
2D-matrix.
> OK, got that.
>
> I wanted to change my current code, which has about 30/40 rows that
> directly fills an Excel worksheet using a reference cell and the
> '.offset'-function, to a code where I fill a matrix with values and then
> use the 'range().resize()'-method to dump this matrix directly into an
> Excel worksheet (as I am looking for speed enhancements of my code).
>
> ****** previous code *******
> Range("A3").Activate
> With ActiveCell
> .Offset(-2, 0).Value = value1
> .Offset(-1, 0).Value = value2
> .Offset(-1, 7).Value = value3
> ...etc...
> End With
> ****** previous code *******
>
> ****** new code ******
> varMatrix = [{,,,,,,,;,,,,,,,;,,,,,,,;,,,,,,,}]
> Range("A1").Resize(4,8).Value = varMatrix
> ****** new code ******
>
> This 4x8 matrix defines the header of a table, which then gets filled with
> >5000 entries. This 2nd matrix will be filled using two regular
> 'for...to...next' loops, so that shouldn't pose a problem.
>
> CoRrRan
>
> On Tue, 31 May 2005 14:00:38 +0100, Bob Phillips wrote:
>
> > You are not creating a 2D array, but an array containing arrays, and you
> > can't drop these onto a worksheet in this way.
> >
> > You need to load it by dimensions.
> >
> > If you don't have much data, you can use something like
> >
> > varMatrix = [{"1,2,"abc";3,4,"xyz";5,6,"hello"}]
> >
> > --
> > HTH
> >
> > Bob Phillips
> >
> > "CoRrRan" <CoRrRan~~[at]~~gmail~~[dot]~~com> wrote in message
> > news:Xns96679254DC784CoRrRan@xxxxxxxxxxxxxxxxxx
> >> I've got a question regarding Arrays and passing them to an Excel
> >> worksheet.
> >>
> >> Here's the code I try to get to work:
> >>
> >> **************************
> >> Sub DumpValues()
> >>
> >> Dim varMatrix()
> >>
> >> varMatrix = Array(Array(1, 2, 3), _
> >> Array(4, 5, 6), _
> >> Array(7, 8, 9) _
> >> )
> >>
> >> Range("A1").Resize(3, 3).Value = varMatrix
> >>
> >> End Sub
> >> **************************
> >>
> >> Can someone tell me why this doesn't work?
> >>
> >> For the sake of the example, I placed integers into the matrix.
However,
> >> I've got a 4x8 string matrix to dump into an Excel worksheet.
> >>
> >> TIA,
> >> CoRrRan
.
- References:
- Array and resize
- From: CoRrRan
- Re: Array and resize
- From: Bob Phillips
- Re: Array and resize
- From: CoRrRan
- Array and resize
- Prev by Date: Re: GET.CELL(4, What is TYPE?
- Next by Date: Re: add a new row
- Previous by thread: Re: Array and resize
- Next by thread: Re: Array and resize
- Index(es):
Relevant Pages
|