Run-time error '1004' . Please help. Request for immediate attent

B

BEETAL

can somebody tell me how to correct this code. I get runtime 1004 error or
type mismatch error(where is the type mismatch!!!). the MMult function doe
not get activated in my VBE.
rewuest for immediate attention.

Option explicit
Option Base 1
Sub mmatrixmulttest()
Dim q, ran, t, X As Double
Dim Randommat() As Variant
Dim CMAT() As Variant
CMAT = Application.Range("VC")
X = UBound(CMAT, 1)
Dim matrixinter() As Variant
Dim matrixinter2() As Variant
ReDim matrixinter(X, X)
ReDim matrixinter2(X, X)
ReDim CMAT(X, X)
ReDim Randommat(1, X)
For q = 1 To X
ran = Application.WorksheetFunction.NormSInv(Rnd())
Randommat(1, q) = ran * t
Next q
Dim Rmattranspose() As Variant
ReDim Rmattranspose(X, 1)
Rmattranspose = Application.WorksheetFunction.Transpose(Randommat)
With Application
matrixinter = .MMULT(Rmattranspose, CMAT)
matrixinter2 = .MMULT(CMAT, CMAT)' this multiplication also does not
'work.Typemismatch is the error
End With
End Sub
 
P

paul.robinson

Hi
X should be a Long
q should be a Long
t is not defined in your code, so is probably always 0. This will make
Randommat 0.
The notation
Dim q, ran, t, X As Double

will make X a double but the rest variants. You want
Dim q as Long, ran as double, t as double, X As Long

see if any of that helps
regards
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top