+ Reply to Thread
Results 1 to 3 of 3

Matrix Dimension as variable/constant

  1. #1
    Registered User
    Join Date
    03-29-2017
    Location
    Madrid
    MS-Off Ver
    2013
    Posts
    38

    Matrix Dimension as variable/constant

    Hello, I am trying to make a function which would use a matrix of (N ,2) dimensions. The function (incomplete) is as following:

    PHP Code: 
    Function APPROACH(P1 As Rangex1 As Doubley1 As Double) As Double
    P1.Rows.Count
    Dim A1
    (1 To 31 To 3) As Double
    Dim A2
    (1 To [B]N[/B], 1 To 2) As Double 
    I get an error message which tells me N must be a constant. N is already defined as P1.Rows.Count and I won't change so, is there a way to change N from variable to constant? Also, I read something about matrices having a 32 dimension limit, is this true?

    Thanks for the help!
    Last edited by gonurvia; 01-17-2018 at 05:01 AM.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Matrix Dimension as variable/constant

    Hi,

    You cannot convert N to a constant since it is not constant. You need to declare a dynamic array and then resize it thus
    Please Login or Register  to view this content.
    you can omit the initial Dim and just use ReDim but I prefer to use both.

    To the best of my knowledge the VBA limit is 60 dimensions (32 is for VB) though if you use anything like that number you must be doing something very strange indeed in my opinion, and have a fairly unique mind to keep them straight in your head!
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    03-29-2017
    Location
    Madrid
    MS-Off Ver
    2013
    Posts
    38

    Re: Matrix Dimension as variable/constant

    Thanks xlnitwit, it worked!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Variable dimension arrays?
    By JasonLeisemann in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-11-2015, 02:38 PM
  2. Eigenvector of matrix for nxn matrix of variable size
    By rocketscientist165 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-14-2014, 10:51 AM
  3. [SOLVED] Changing dimension matrix multiplication
    By vizzkid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2013, 09:02 AM
  4. Performing functions on array while holding dimension constant
    By ath1337 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2012, 02:50 PM
  5. Feature Dimension Trace Matrix
    By mycon73 in forum Excel General
    Replies: 0
    Last Post: 12-03-2010, 12:57 PM
  6. Matrix Dimension
    By Michelle in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-24-2005, 01:50 PM
  7. [SOLVED] Improrting Text file to a matrix when things are not constant.
    By underdrain in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-27-2005, 11:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1