Message Box: The given key was not present in the dictionary

when I pass the key shivam then out showing “How are you”

But when I pass the value Johan Then showing this error

“Message Box: The given key was not present in the dictionary.”

Dose any one know how to solve this and what the cause of this error

Somebody help me this and connect withme on +917307745881

Probably the name in the spreadsheet has an extra space like "Johan "

You should look in the Locals panel to see these kind of things as you’re debugging and it stops on the error.

You should put the Message Box activity outside the For Each Row loop. Otherwise you will get the error message for any name that is not in the first row.

No such extra space i have checked deeply.



in your messagebox instead

you cant use dicNames(“Johan”) as in the first iteration your dictionary only contains “Shivam”

Hello @pankaj_singh3

Here you are creating a dictionary and trying to display the value using the key. So the first thing is reading the loop through excel and create the dictionary. So once it is created then you can use the dictionary with key to fetch the value.

Here Johan is the second row in the Excel and in the first loop if you try to give Johan as key it will throw the error.

So you can use the message box out of the for loop, then it should work

Thanks to all of you .now its working

1 Like

Good to hear that @pankaj_singh3 :slight_smile: