Hola,soy nueva en esto asi que espero que podais ayudarme...estoy haciendo mi proyecto fin de carrera y para ello necesito el VBA de excell.
Me encontrado con el error 13(no coinciden los tipos) y por mas que miro no se porque os pongo la funcion:
Function Radiacion_extraterrestre(f As Integer, t_orto As Single, t_ocaso As Single, h As Integer, Ndia As Integer, col_dia As Integer, col_Go As Integer) As Single
Dim pi As Double
Dim m As Double
Dim T As Single
Dim TST(24) As Single
Dim w_rad(24) As Double
Dim l As Double
Dim d As Double
Dim d_rad As Double
Dim b As Double
Dim lat As Double
Dim cte As Integer
Dim Go As Double
Dim Kt As Double
Dim Dh As Double
Dim R_directa As Double
Dim lon As Single
Dim lat_rad As Double
Dim lon_rad As Single
Dim lon_huso As Single
Dim gamma As Single
Dim TSV(24) As Single
Dim Et As Single
Dim AO As Integer
Dim w(24) As Double
Dim N As Integer
Dim wo As Double
pi = 3.14159265358979
'Primero lectura orden de día = N
N = Ndia
'Latitud y longitud del punto de observación y longitud huso.Datos dados
lat = H2.Cells(8, 2).Value + H2.Cells(8, 3).Value / 60 + H2.Cells(8, 4).Value / 3600
lon = H2.Cells(9, 2).Value + H2.Cells(9, 3).Value / 60 + H2.Cells(9, 4).Value / 3600
lat_rad = lat * pi / 180
lon_rad = lon * pi / 180
lon_huso = H2.Cells(10, 2).Value + H2.Cells(10, 3).Value / 60 + H2.Cells(10, 4).Value / 3600
'Declinación solar d (º)(Aprox. Cooper)
d = 23.45 * Sin(2 * pi / 365 * (N + 284))
'Ecuación del tiempo Et (min) (Aprox. Spencer)
gamma = WorksheetFunction.Radians(360 / 365 * (N - 1)) 'en rad
Et = (0.000075 + 0.001868 * Cos(gamma) - 0.032077 * Sin(gamma) - 0.014615 * Cos(2 * gamma) - 0.04089 * Sin(2 * gamma)) * 229.18
'Tiempo Solar Verdadero (h)
If N > 87 And N < 303 Then
AO = 2
ElseIf N <= 87 Then
AO = 1
ElseIf N >= 303 Then
AO = 1
End If
TSV(h) = h - AO + (lon - lon_huso) / 15 + Et / 60 - 12
TSV(h - 1) = (h - 1) - AO + (lon - lon_huso) / 15 + Et / 60 - 12
'Ángulo Horario Solar (º)
w(h) = 15 * TSV(h)
w(h - 1) = 15 * TSV(h - 1)
'angulo horario en radianes
w_rad(h) = w(h) / 180 * pi
w_rad(h - 1) = w(h - 1) / 180 * pi
'angulo diario
l = 2 * pi * (N - 1) / 365
'declinación solar(º) - Modelo Spencer
d = (180 / pi) * (0.006918 - 0.399912 * Cos(l) + 0.070257 * Sin(l) - 0.006758 * Cos(2 * l) + 0.000907 * Sin(2 * l) - 0.002697 * Cos(3 * l) + 0.00148 * Sin(3 * l))
'declinación solar (rad)
d_rad = d * pi / 180
'distancia solar-tierra(unidades astronomicas) Spencer 1971
'b=1/d^2
b = 1.00011 + 0.034221 * Cos(l) + 0.00128 * Sin(l) + 0.000719 * Cos(2 * l) + 0.00077 * Sin(2 * l)
'wo angulo solar a mitad del intervalo de tiempo entre t1 y t2
wo = (w_rad(h) - w_rad(h - 1)) / 2
'radiación global extraterrestre
If h >= t_orto And h <= t_ocaso Then
cte = 1368 ' constante solar (w/m2)
Go = cte * b * [Sin(d_rad) * Sin(lat_rad) + (Cos(d_rad)*(24/pi) * Cos(pi/24) * Cos(wo))]
H7.Cells(f, col_Go).Value = Go
Else
H7.Cells(f, col_Go).Value = 0
End If
End Function
Cuando le doy a ejecutar me da el error en Go espero contestación y daros la gracias de ante mano me corre un poco de prisa porque hasta que no encuentre una solución no puedo seguir
GRACIAS!