Vicente Fachina
07-01-2017 17:20:07
Prezados,
Preciso reaprender Excel VBA porque não o uso há mais de 30 anos. Segue parte do códiigo, em cuja última linha colada ocorre erro ao aplicar comando de inversão de matriz.
Grato por vossa ajuda.
Vicente
Option Explicit
Option Base 1
Sub Entropia()
Rem INICIALIZAÇÃO
Dim i As Integer, j As Integer, nmatriz As Integer
Dim valormatriz As Double, Entropia As Double
Dim Demanda() As Double, InversoDemanda() As Double, Disponibilidade() As Double, MatrizEntropia() As Double
nmatriz = Range("C2").Value
Rem INPUT MATRIZ DEMANDA & CALCULO MATRIZ INVERSA
ReDim Preserve Demanda(1 To nmatriz, 1 To nmatriz) As Double
For i = 1 To nmatriz
For j = 1 To nmatriz
valormatriz = Cells(20 + i, 2 + j).Value
Demanda(i, j) = valormatriz
Next
Next
ReDim InversoDemanda(1 To nmatriz, 1 To nmatriz) As Double
InversoDemanda() = WorksheetFunction.MInverse(Demanda()) 'ERRO EM TEMPO DE EXECUÇÃO 13
Preciso reaprender Excel VBA porque não o uso há mais de 30 anos. Segue parte do códiigo, em cuja última linha colada ocorre erro ao aplicar comando de inversão de matriz.
Grato por vossa ajuda.
Vicente
Option Explicit
Option Base 1
Sub Entropia()
Rem INICIALIZAÇÃO
Dim i As Integer, j As Integer, nmatriz As Integer
Dim valormatriz As Double, Entropia As Double
Dim Demanda() As Double, InversoDemanda() As Double, Disponibilidade() As Double, MatrizEntropia() As Double
nmatriz = Range("C2").Value
Rem INPUT MATRIZ DEMANDA & CALCULO MATRIZ INVERSA
ReDim Preserve Demanda(1 To nmatriz, 1 To nmatriz) As Double
For i = 1 To nmatriz
For j = 1 To nmatriz
valormatriz = Cells(20 + i, 2 + j).Value
Demanda(i, j) = valormatriz
Next
Next
ReDim InversoDemanda(1 To nmatriz, 1 To nmatriz) As Double
InversoDemanda() = WorksheetFunction.MInverse(Demanda()) 'ERRO EM TEMPO DE EXECUÇÃO 13