mardi 28 novembre 2017

VBA - IF statement does not work

Sometimes I wonder why I even program anymore or why I use VBA... I have following code:

Private Sub CommandButton1_Click()
    Dim bSuccess As Boolean
    bSuccess = modGenerateGRList.GenerateGRList

    bSuccess = False

    If bSuccess Then
        CommandButton1.Select
        Selection.Delete
    End If
End Sub

It keeps deleting my button. It's supposed to delete my button when the called funktion was successfull. How can If bSuccess Then or If bSuccess = True Then result to true?

I used MsgBox bSuccess one line before the if, to show me that bSuccess was false and it would still delete my button.

When I delete the line bSuccess = modGenerateGRList.GenerateGRList, my code works fine. How can the function modGenerateGRList.GenerateGRList influence my code?

Aucun commentaire:

Enregistrer un commentaire