Tengo una función if que no me funciona por que los resultados se producen cuando abro mi archivo..

Tengo esa función IF que no me funciona porque los resultados de ella depende de los valores que esta en un modulo en Open es decir cuando abro mi libro, mi pregunta que debo hacer.

Cual seria la solución:

Gracias

If Sheets("MKP").Range("AE" & Bos_Satir).Value >= Sheets("MKP").Range("AJ" & Bos_Satir).Value Then
Sheets("MKP").Range("AO" & Bos_Satir).Value = "Besetzt"
Else
Sheets("MKP").Range("AO" & Bos_Satir).Value = "Frei"

En open tengo lo siguiente

Private Sub Workbook_Open()

pass = "chevo"
Sheets("MKP").Unprotect pass
lastrow = Sheets("MKP").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("MKP").Range("AE:AN").Locked = False
With Range("AE2:AI" & lastrow)
.Formula = "=sum(G2:G100)"
End With
'
With Range("AJ2:AN" & lastrow)
.Formula = "=sum(O2:O100)"
End With
'
Sheets("MKP").Range("AE:AN").Locked = True
'
Sheets("MKP").Range("BI:BR").Locked = False
With Range("BI2:BM" & lastrow)
.Formula = "=sum(AY2:AY100)"
End With
'
With Range("BN2:BR" & lastrow)
.Formula = "=sum(BD2:BD100)"
End With
'
Sheets("MKP").Range("BI:BR").Locked = True
Sheets("MKP").Range("AE:AN").Locked = False
With Range("CC2:CG" & lastrow)
.Formula = "=sum(AE2:AE100)-sum(Aj2:AJ100)"
End With
'Sheets("MKP").Range("AE:AN").Locked = True
Sheets("MKP").Range("Bj:AR").Locked = False
With Range("CH2:CL" & lastrow)
.Formula = "=sum(Bj2:Bj100)-sum(BN2:BN100)"
End With
Sheets("MKP").Range("BJ:AR").Locked = True
Sheets("MKP").Protect pass
UserForm1.Show
End Sub

Añade tu respuesta

Haz clic para o