21.12.2012 Views

Programación Visual Basic (VBA) para Excel y Análisis ... - TEC-Digital

Programación Visual Basic (VBA) para Excel y Análisis ... - TEC-Digital

Programación Visual Basic (VBA) para Excel y Análisis ... - TEC-Digital

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>VBA</strong> <strong>para</strong> <strong>Excel</strong> M.Sc. Walter Mora F., M.Sc. José Luis Espinoza B. 40<br />

End Sub<br />

Formula = Cells(6, 2)<br />

xval = Cells(5, 4)<br />

OK = Fun.StoreExpression(Formula) ’ leer ’Formula’ y analizar sintaxis<br />

If Not OK Then GoTo Error_Handler ’ si hay un error va al manejador de errores<br />

Cells(6, 3) = "f(" + str(valx) + ")= "<br />

Cells(6, 4) = Fun.Eval1(xval) ’evaluar en la fórmula actual<br />

If Err Then GoTo Error_Handler ’si hay error...<br />

Error_Handler: Cells(1,1)= Fun.ErrorDescription ’Mensaje de error<br />

1. Las variables deben empezar con una letra, por ejemplo t, xi, time. Para evitar la ambigüedad, xy se<br />

interpreta como una variable. El producto requiere *, es decir x*y es el producto de x e y . Se permite<br />

multiplicación implícita solo <strong>para</strong> x, y, y z , o sea, por ejemplo 2x se interpreta como 2*x<br />

2. Los argumentos de una función, si hay varios, se se<strong>para</strong>n con una coma, por ejemplo max(x,y), root(x,y).<br />

3. Las expresiones lógicas retornan 1 o 0 . Como ejemplo de estas expresiones tenemos (x

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!