Indenting can help reveal issues:
Code:
Do
admixxin = InputBox("Add the date of admission to hospital!", "Admitted to Hospital", , 3000, 3000)
If StrPtr(admixxin) = 0 Then
MsgBox "You have pressed cancel and the command will stop here!!!"
Exit Sub
End If
' the above sequence is in place so that if no admission date is available the command will stop here.
licenzjat = InputBox("Add the date of discharge from Hospital", "Discharged from Hospital", "", 9000, 3000)
sameta = ahhartaxahar
If IsDate(licenzjat) = False Then
If admixxin >= tibda Then
hstay = ahhartaxahar - admixxin 'patient still in hospital by end of month.
ElseIf admixxin < tibda Then
hstay = ahhartaxahar - tibda + 1 ' patient in hospital throughout the month
End If
Else
If admixxin >= tibda And CDate(licenzjat) <= ahhartaxahar Then
hstay = CDate(licenzjat) - admixxin - 1
ElseIf admixxin < tibda And CDate(licenzjat) <= ahhartaxahar Then
hstay = CDate(licenzjat) - tibda
End If
messagg = MsgBox("Was the resident admitted to hospital again?", vbYesNoCancel, "Hospital admission no " & numru)
tothstay = tothstay + hstay
numru = numru + 1
End If
Loop While Message = vbYes
Loop line is in wrong place. It has interrupted an existing If Then Else block. Without the complete procedure, not sure where should be. The above correction will probably result in an unpaired End If below the Loop.