So from what I can see of your code, the issue is what I was hinting at before
Unless you have this line:
Public ARRIVAL As Boolean
then your boolean is only local to the specific function. So it is actually two different instances of a boolean variable called ARRIVAL, one in each of your subs.
If my understanding is correct, then there are a couple ways to fix it. You can put in the above line of code, or similarly:
Global ARRIVAL As Boolean
-Either of these two lines would work, but they need to be placed outside your sub
With either of these lines, your Check_ARRIVAL_Code function will set the ARRIVAL to true or false, and then the btn sub would check the value of that variable. If you want to implement this, make sure you get rid of the dim ARRIVAL as Boolean line because this will create a local instance and ignore the global.
The alternate fix, and maybe the better one depending on the rest of your code, is to have your function return the true or false value, rather than setting a variable. Your code would then look like this:
Public Sub Btn_Send_Arrival_Click()
MsgBox "before boolean is true"
'If cell have values, button works and send values
If Check_ARRIVAL_Code = True Then
MsgBox "after boolean is true"
'Send Comp.1 Bagagge
Sheet1.Range("U34").Value = Sheet5.Range("T143").Value
End If
End Sub
'Check when pessing button if the two ceels are empty
Public Function Check_ARRIVAL_Code() As Boolean
If Sheet3.Range("CD11").Value = "" And Sheet3.Range("CE12").Value = "" Then
MsgBox "Please put values in the empty cells"
Check_ARRIVAL_Code = False
Else
Check_ARRIVAL_Code = True
End If
End Function
Let me know if this helps.
Bookmarks