Crear Función personalizada en Excel 2010

Saludo Cordial
Experto.
Me ha parecido muy interesante el tema de crear sus propias funciones en Excel pero manejo muy poco el tema de macros he intentado hacer funciones que me resuma las siguientes fórmulas que te presento a continuación, pero no he podido tener éxito.


=(SI(E19>=10;(SI(ESERROR(HALLAR(",";E19;1)-1);(REDONDEAR(EXTRAE(DECIMAL(E19;1);1;HALLAR(",";DECIMAL(E19;1);1)-1);(2-LARGO(EXTRAE(DECIMAL(E19;1);1;HALLAR(",";DECIMAL(E19;1);1)-1)) )));(REDONDEAR(EXTRAE(E19;1;HALLAR(",";E19;1)-1);(2-LARGO(EXTRAE(E19;1;HALLAR(",";E19;1)-1)))))));SI(Y(E19>=1;E19<10);DECIMAL(E19;1);SI(E19<1;(DECIMAL(E19;(MIN(ENCONTRAR({1;2;3;4;5;6;7;8;9};(SUSTITUIR(E19;"0";"POR"))&1234567890)))-(SI(DERECHA(DECIMAL(E19;(MIN(ENCONTRAR({1;2;3;4;5;6;7;8;9};(SUSTITUIR(E19;"0";"POR"))&1234567890)))-1);2)="00";2;1))));""))))*1


=REDONDEAR(D19;LARGO(I19)-SI(ESERROR(ENCONTRAR(",";I19));LARGO(I19);ENCONTRAR(",";I19)))


La primera es para realizar redondeo a dos cifras significativas.
La segunda es para reportar un dato dependiendo de las cifras significativas obtenidas en el resultado anterior.

He investigado un poco mas y llevo la macro para dar solución a la primera formula así:

ublic Function CIFRAS2(rCell As Variant, vAnswer As Variant) As String
Dim dDigits As Double
Dim iRoundDigits As Integer
Dim sFormatstring As String
If TypeName(vAnswer) = "Boolean" Then Exit Function
If vAnswer = "" Then Exit Function
iRoundDigits = CInt(Application.Max(1, vAnswer))
If IsNumeric(rCell) And rCell <> "" Then
sFormatstring = "0"
If rCell = 0 Then
dDigits = 3
Else
dDigits = Log(Abs(rCell)) / Log(10)
dDigits = -Int(dDigits) + iRoundDigits - 1
dDigits = Application.Min(Len(Abs(rCell)), dDigits)
End If
If dDigits >= 1 Then
If Int(rCell) = 0 Then
sFormatstring = sFormatstring & "." & String(dDigits, "0")
Else
sFormatstring = sFormatstring & "." & String(dDigits, "0")
End If
ElseIf dDigits < 0 Then
sFormatstring = sFormatstring & "." _
& String(iRoundDigits - 1, "0") & "E+00"
End If
CIFRAS2 = "±" & " " & Format(rCell, sFormatstring) & " " & "%"
End If
End Function

Pero por mas que lo intentado, cambiando la declaración de las variables de texto a numero no he podido entregar al final de la macro un dato que se pueda trabajar como numero.

por favor me colaboran con esto.


Muchas gracias por tu colaboración.
Víctor Manuel.

Añade tu respuesta

Haz clic para o