... 2 Ranges go in ... 1 Array Formula will spill out...
Take two ranges in excel, convert them to 1d c arrays ready to go into a c function call.
Pass in the buffer size as the width and height of the output array as allocated in VBA.
Return the buffer size modified by c to VBA.
Return a 2d buffer populated by C to VBA.
Convert it to a Array Formula.
Built for x64 excel
Post the VBA in a Module in Excel.
Create two input ranges in excel, and pass it into the vba function. Press Ctrl+Shift+Enter on older versions of excel to force a spill for the array formula output.
=my_mmult_func(B15:D16, F15:G17)
If it detects the Array Formula correctly there should be some curly brackets that surround the formula.
Or from the Visual Basic
editor on Excel, run a test function like this
Sub test_twod_array_func()
Range("L7").FormulaArray = my_mmult_func(Range("B15:D16"), Range("F15:G17"))
End Sub
Note the print statments in c are basically useless in VBA.
https://renenyffenegger.ch/notes/development/languages/VBA/Calling-DLLs/byRef-byVal
http://www.vbforums.com/showthread.php?495753-Passing-2D-Array-from-VBA-to-C
https://www.exceltip.com/custom-functions-in-vba/create-vba-function-to-return-array.html
https://github.com/keithalewis/xll12
https://github.com/VBA-tools/VBA-JSON
https://www.codeproject.com/Articles/17733/A-C-DLL-for-Excel-that-uses-Arrays-and-Ranges