Pergunta

I have this following code which is showing this error: "Compile error: Sub or function not defined"

Dim wattarray() As Integer 
Dim x As Integer

x = Sheets("Names").Range("ai4")
ReDim wattarray(x) As Integer
Dim battarray As Variant
If condition Then
    battarray = Array("32", "34", "36")
End if

For z = 1 To x
    watt = (kw * 1000 * dmarg) / (ieff * battarray(z) * tfac * agefac * 6 * nstring)
    wattarry(z) = watt      "this line shows the error"           
    watt = wattarry(1)
Next z

battarray and wattarray have the same size as variable x

Can some one help me fix this...

Foi útil?

Solução

wattarray(), not wattarry() !

Make sure you use Option Explicit in every module. This can be automated by changing VBE preferences: Tools/ Options/ Require Variable Declaration.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top