If you remember the story of Joseph, one of the last verses in those chapters, you see an interesting verse. "What was meant as evil, God uses for good" is a paraphrase of that verse (the full verse reads "But as for you, you meant evil against me; but God meant it for good, in order to bring it about as it is this day, to save many people alive," Genesis 50:20).
This is a good verse to remember when things don't go our way. This means that there is a greater purpose for what's happening to us, that God is still going to use a situation for His glory.
What situation are you going through right now that this passage (and promise) can be applied to your life? God is always bigger than your situation.