+ Reply to Thread
Results 1 to 8 of 8

Matrix multiply/division

  1. #1
    Registered User
    Join Date
    11-02-2010
    Location
    Prague, CZ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Matrix multiply/division

    Hello,
    i would like to ask for help with the following VBA code. I need to write a funciton that multiplies or divides a matrix in Excel by a double value. I want to call the function like

    Please Login or Register  to view this content.
    where B2:C3 is an example of some selected area with double values. Of course, area of the same size is selected when the function is executed. I just keep getting #Value! error.


    Please Login or Register  to view this content.
    Thanks for any ideas,
    David
    Attached Files Attached Files

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Matrix multiply/division

    You don't need VBA for this. In some 2x2 range, array-enter =A1*B2:C3
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    11-02-2010
    Location
    Prague, CZ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Matrix multiply/division

    I know I don't need VBA for this example, this is just part of some other code i need to get working. The general question is how to get a Variant (Range) as a parametr, multiply or divide the values with double and return it back to cells in worksheet.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Matrix multiply/division

    Please Login or Register  to view this content.



  5. #5
    Registered User
    Join Date
    11-02-2010
    Location
    Prague, CZ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Matrix multiply/division

    Quote Originally Posted by snb View Post
    Please Login or Register  to view this content.
    This code is nice, but would it be possible to have the number we multiply with as a double variable?

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Matrix multiply/division

    Meaning ?

    Please Login or Register  to view this content.
    PS. in the worksheet you can enter
    =matrixmultiply(A1:E5)
    no need to use a matrix-formula
    Last edited by snb; 11-02-2010 at 01:00 PM.

  7. #7
    Registered User
    Join Date
    11-02-2010
    Location
    Prague, CZ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Matrix multiply/division

    Quote Originally Posted by snb View Post
    Meaning ?

    Please Login or Register  to view this content.
    PS. in the worksheet you can enter
    =matrixmultiply(A1:E5)
    no need to use a matrix-formula
    I meant that the double value is product of some other VBA code. For example i would like to count an average of the area and then divide every single value by this average.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Matrix multiply/division

    All at once:
    Please Login or Register  to view this content.
    Last edited by snb; 11-02-2010 at 01:47 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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