Advertisement
Guest User

123123

a guest
Nov 21st, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. Sub Estadisticas()
  2.  
  3. Dim RutPacienteMayor As Integer
  4. Dim RutPaciente As Long
  5. Dim X As Integer
  6. Dim PromedioEdad As Double
  7. Dim Edad As Integer
  8. Dim SumaEdades As Integer
  9. Dim UltimaFila As Double
  10. Dim PromedioDiasGraves As Double
  11. Dim Dias As Integer
  12. Dim SumaDias As Integer
  13. Dim i As Integer
  14.  
  15. RutPacienteMayor = 0
  16.  
  17. If (RutPaciente > RutPacienteMayor) Then
  18. RutPacienteMayor = RutPaciente
  19. End If
  20.  
  21. MsgBox ("El Rut del Paciente Mayor" & RutPacienteMayor & " ")
  22.  
  23. UltimaFila = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count
  24.  
  25. For X = 2 To UltimaFila
  26. Edad = Range("D" & X)
  27. SumaEdades = SumaEdades + Edad
  28. Next
  29. If SumaEdades > 1 Then
  30. PromedioEdad = Round(SumaEdades / (UltimaFila - 1), 0)
  31. End If
  32. MsgBox ("El promedio es" & PromedioEdad & " ")
  33.  
  34. For X = 2 To UltimaFila
  35. Dias = Range("K" & X)
  36. If Dias >= 1 Then
  37. SumaDias = SumaDias + Dias
  38. i = i + 1
  39. End If
  40. Next
  41. If SumaDias > 1 Then
  42. PromedioDiasGraves = Round(SumaDias / i, 0)
  43. End If
  44. MsgBox ("El promedio es" & PromedioDiasGraves & " ")
  45.  
  46. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement