Professional Documents
Culture Documents
Sub Macro2
Sub Macro2
Next j
Range("J37").Formula = "=Average(J7:J36)"
End Sub
Function Vlookup(N As Variant, Rango1 As Range, c As Integer) As Integer
Vlookup = Excel.WorksheetFunction.Vlookup(N, Rango1, c)
End Function
Sub Macro4()
Private Sub CommandButton1_Click()
Dim TE As Integer, PRO As Integer, M As Variant, M2 As Variant, S2 As Variant
Dim FINAL As Integer, S As Variant, Sd As Double, Sd2 As Double
M = Cells(3, 7).Value
S = Cells(4, 7).Value
PRO = Cells(3, 11)
Range("S6:U35").ClearContents
REP = InputBox("Digite el nmero de Replicas (No mayor que 30):", "NUMERO
DE REPLICAS")
If (REP > 30) Then
MsgBox "El nmero de replicas excede a la capacidad de corridas", vbOKOnly, "
!! LO SIENTO!!"
Exit Sub
End If
For i = 1 To REP
'Limpipeza
Range("H6:P29").ClearContents
Range("k4").ClearContents
Range("N4").ClearContents
For J = 6 To 29
Cells(J, 8).Value = Rnd
Cells(J, 15).Value = 0
Next J
'Generacin de la demanda
For h = 6 To 29
N = Cells(h, 8).Value
D = Round(NORMAL(N, M, S), 0)
Cells(h, 9).Value = D
Next h
M2 = Cells(5, 3).Value
S2 = Cells(5, 5).Value
Sum = 0
'Generacin de los tiempos de entrega
For k = 10 To 19
Cells(k, 2).Value Rnd
N2 = Cells(k, 2).Value
Cells(k, 3).Value = Round(NORMAL(N2, M2, S2), 0)
Next k
'Desviacin estandar durante el tiempo de entrega
Sd2 = Sqr(M2 * (S) ^ 2 + M * (S2) ^ 2)
Cells(4, 14).Value = Sd2
'Probabilidad de que haya existencias
Range("K4").Formula = "=Normdist(K3,G3,N4,1)"
J = 10
cont = 0
Cells(6, 10).Value = Cells(2, 11).Value
For x = 6 To 29
II = Celss(x, 10).Value
D = Cells(x, 9).Value
Q = Cells(x, 11).Value
FINAL = Cells(x, 13).Value
FALT = Cells(x, 13).Value
FINAL = II + Q + FALT - D
If (FINAL <= 50) And (TE <= 0) Then
cont = cont + 1
Cells(x, 14).Value = 1
Cells(x, 15).Value = cont
Cells(x, 16).Value = Cells(J, 3).Value
J=J+1
TE = Cells(x, 16).Value
If (x + (TE + 1)) <= 29 Then
Cells(x + TE, 11).Value -Cells(2, 7).Value
End If
Else
Cells(x, 14).Value = 0
End If
If (FINAL <= 0) Then
Cells(x, 12).Value = 0
Cells(x, 13).Value = FINAL * (-1)
Cells(x + 1, 10).Value = FINAL
Else
Cells(x, 12).Value = FINAL
Cells(x + 1, 10).Value = Cells(x, 12).Value
Cells(x, 13).Value = 0
End If
TE = TE - 1
Cells(30, 10).Value = ""
Next x
Cells(i + 5, 19).Value = Cells(31, 14)
Cells(i + 5, 20).Value = Cells(31, 12)
Cells(i + 5, 21).Value = Cells(31, 13)
Var = "REPLICA NUMERO " + Str(i)
MsgBox Var, vbKOnly, "REPLICAS"
Next i
Range("S36").Formula = "=average(S6:S35)"
Range("T36").Formula = "=average(T6:T35)"
Range("U36").Formula = "=average(U6:U35)"
Range("C7").Formula = "=1-(U36/G2)"
End Sub
End Function