Visual Basic - ERROR TIPO 13

Life is soft - evento anual de software empresarial
 
Vista:

ERROR TIPO 13

Publicado por paola urgiles (1 intervención) el 31/10/2016 22:27:37
AYUDA NOSE PORQUE ME SALE EL ERROR 13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Sub Navidad()
    Dim Extras As Integer
    Dim Ausencia As Integer
    Dim Sobretiempo As Double
    Dim Gratificacion As Double
    Extras = Worksheets("Hoja1").Range("A3").Value
    Ausencia = Range("B3").Value
    Gratificacion = Range("C3").Value
    Sobretiempo = (Extras - 2 / 3 * Ausencia)
    If Sobretiempo > 40 Then
    Gratificacion = 500
    End If
    If Sobretiempo > 30 And Sobretiempo <= 40 Then
    Gratificacion = 400
    End If
    If Sobretiempo > 20 And Sobretiempo <= 30 Then
    Gratificacion = 300
    End If
    If Sobretiempo > 10 And Sobretiempo <= 20 Then
    Gratificacion = 200
    End If
    If Sobretiempo > 0 And Sobretiempo <= 10 Then
    Gratificacion = 100
    End If
    If Sobretiempo = 0 Then
    Gratificacion = 0
    End If
    Gratificacion = ("C3")
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Antoni Masana
Val: 1.259
Plata
Ha mantenido su posición en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

ERROR TIPO 13

Publicado por Antoni Masana (558 intervenciones) el 01/11/2016 10:35:10
La macro un poco más simple

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Sub Navidad()
    Dim Extras As Integer
    Dim Ausencia As Integer
    Dim Sobretiempo As Double
    Dim Gratificacion As Double
 
    Extras = Worksheets("Hoja1").Range("A3").Value
    Ausencia = Range("B3").Value
    Gratificacion = Range("C3").Value
    Sobretiempo = (Extras - 2 / 3 * Ausencia)
 
    If Sobretiempo >= 41 Then Gratificacion = 500
    If Sobretiempo <= 40 Then Gratificacion = 400
    If Sobretiempo <= 30 Then Gratificacion = 300
    If Sobretiempo <= 20 Then Gratificacion = 200
    If Sobretiempo <= 10 Then Gratificacion = 100
    If Sobretiempo  =  0 Then Gratificacion = 0
 
    Gratificacion = ("C3")
End Sub

Esta línea no tiene sentido a menos que el Sobretiempo de un valor negativo con lo que Gratificacion tendria el valor anterior.

¿Que se supone que hace esto: Gratificacion = ("C3")?

El error 13 es un Type mismatch y significa en castellano: No coinciden los tipos

Significa que en una variable numerica Gratificacion definida como Double estas asignando un String --> "C3"

Saludos.
\\//_
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar