jeudi 3 mai 2018

VBA Excel Not Like String If Statement

I'm trying to write an "If" statement that checks to see if a the Key that corresponds to a Player object in a (Scripting.)Dictionary called Players has a String value that contains the letter "P."

I must be missing some VBA syntactical sugar, but I can't seem to find the answer to what I'm doing wrong anywhere.

My statement right now is:

For Each Key In Players.Keys()
    If Not (Players(Key).Position Like "*P*") Then 'something'
    End If
Next Key

However, it selects the first dictionary entry it loops through even though the Position property has a P in it.

In this case Player(Key).Position = "RP," which I would like to then skip over the "Then" statement. It currently does not work.

Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire