Results 1 to 8 of 8

Matrix multiply/division

Threaded View

  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

    {=MatrixMultiply(B2:C3)}
    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.


    Function MatrixMultiply(ByRef area As Range) As Variant()
        
        Dim MultiplyNumber As Double
        Dim i As Integer
        Dim MatrixResult As Range
                
            MultiplyNumber = 2
            MatrixResult = area.Value
            
            For i = 0 To area.Cells.Count
                MatrixResult(i) = area(i) * 2
            Next i
            
            'other approach
    
            'For Each cellItem In normVect
            '    cellItem.Value = cellItem * 2
            'Next cellItem
                
            MatrixMultiply = MatrixResult
                
    End Function
    Thanks for any ideas,
    David
    Attached Files Attached Files

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