Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2007

Tip: Looking for answers? Try searching our database.

Array function with more than 29 arguments

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
VirtualReal@gmail.com - 15 Apr 2007 14:42 GMT
Hi all,

I want to write more than 29 array varibles (defined in a my VBA code)
in a workbook range. Is there a way to accomplish this?

Here is my sample code (check my remark):

Sub ArrayTest()
   Dim Array1 As Variant
   Dim Array2 As Variant
   Dim CompleteArray As Variant

   Array1 = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
   Array2 = Array(16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30)
   CompleteArray = Array(Array1, Array2)

   Range("A1:AD1").Value = (CompleteArray) 'Result: Range A1 & B2 is
empty while the rest is #N/A
End Sub

Thanks for any feedback!

- Bas
RB Smissaert - 15 Apr 2007 15:00 GMT
Not sure what you are trying to achieve, but maybe something like this will
work for you:

Sub test()

  Dim i As Long
  Dim arr(1 To 1, 1 To 30) As Long

  For i = 1 To 30
     arr(1, i) = i
  Next i

  Range("A1:AD1").Value = arr

End Sub

RBS

> Hi all,
>
[quoted text clipped - 20 lines]
>
> - Bas
Dana DeLouis - 15 Apr 2007 15:02 GMT
Hi.  It doesn't work like a math program, but here's one way in Excel:

Sub ArrayTest()
   Dim v1 As Variant
   Dim v2 As Variant
   Dim m As Variant

   v1 = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
   v2 = Array(16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30)

   m = Array(v1, v2)
   With WorksheetFunction
     m = .Transpose(.Transpose(m))
   End With
   [A1].Resize(UBound(m, 1), UBound(m, 2)) = m
End Sub

Signature

HTH   :>)
Dana DeLouis
Windows XP & Office 2007

> Hi all,
>
[quoted text clipped - 20 lines]
>
> - Bas
Art - 15 Apr 2007 15:40 GMT
Dana,

What happened??  You took an array with 2 elements, each of which was a
variant holding an array.  You transposed it twice and got back a 2-dim
array?  How does that work?

> Hi.  It doesn't work like a math program, but here's one way in Excel:
>
[quoted text clipped - 37 lines]
> >
> > - Bas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.