In Ezekiel 29:11-15
No foot of man shall pass through it, nor foot of beast shall pass through it, neither shall it be inhabited forty years. And I will make the land of Egypt desolate in the midst of the countries that are desolate, and her cities among the cities that are laid waste shall be desolate forty years: and I will scatter the Egyptians among the nations, and will disperse them through the countries. Yet thus saith the Lord GOD; At the end of forty years will I gather the Egyptians from the people whither they were scattered: And I will bring again the captivity of Egypt, and will cause them to return into the land of Pathros, into the land of their habitation; and they shall be there a base kingdom. It shall be the basest of the kingdoms; neither shall it exalt itself any more above the nations: for I will diminish them, that they shall no more rule over the nations.
The first problem people have in understanding this passage in Ezekiel 29:17-21 is chronological. While we are given a period of forty years, we are not given a starting point. Babylon's rule over the Levant was a period of seventy years, from the fall of the Assyrian kingdom in October of 609 BC to the fall of Babylon on the night of October 13, 539 BC. This passage in Ezekiel was written on January 26, 586 BC, nearly six months prior to the fall of Jerusalem.
However, according to Ezekiel 29:17-21 Egypt will be given to Nebuchadnezzar for his service in the destruction of Tyre, whose judgments are described in the three preceding chapters.
In Ezekiel 29:17-21 (betweent  is what I added)
And it came to pass in the seven and twentieth year, in the first month, in the first day of the month [April 16, 570 BC], the word of the LORD came unto me, saying, Son of man, Nebuchadrezzar king of Babylon caused his army to serve a great service against Tyrus: every head was made bald, and every shoulder was peeled: yet had he no wages, nor his army, for Tyrus, for the service that he had served against it: Therefore thus saith the Lord GOD; Behold, I will give the land of Egypt unto Nebuchadrezzar king of Babylon; and he shall take her multitude, and take her spoil, and take her prey; and it shall be the wages for his army. I have given him the land of Egypt for his labour wherewith he served against it, because they wrought for me, saith the Lord GOD. In that day will I cause the horn of the house of Israel to bud forth, and I will give thee the opening of the mouth in the midst of them; and they shall know that I am the LORD.
The siege of Tyre by Nebuchadnezzar occurred over a period of 13 years from 586 to 573 BC. Whenever this "gift" to Nebuchadnezzar would occur, it must begin after the siege of Tyre. Specifically, this occurred in 564 BC and ended with the arrival of Cambyses in 525 BC.