Hadithcore
Al-Adab Al-Mufrad, 666
sahih· Al-Albani

Mu'awiya ibn Abi Sufyan said on the minbar, "None can withhold what You give nor give what Allah withholds. The effort of a person who makes an effort does not benefit him. When Allah desires good for a person, He gives him understanding in the deen." He added, "I heard these words from the Prophet, (ﷺ)."

حَدَّثَنَا إِسْمَاعِيلُ قَالَ‏:‏ حَدَّثَنِي مَالِكٌ، عَنْ يَزِيدَ بْنِ زِيَادٍ، عَنْ مُحَمَّدِ بْنِ كَعْبٍ الْقُرَظِيِّ، قَالَ مُعَاوِيَةُ بْنُ أَبِي سُفْيَانَ عَلَى الْمِنْبَرِ‏:‏ إِنَّهُ لاَ مَانِعَ لِمَا أَعْطَيْتَ، وَلاَ مُعْطِيَ لِمَا مَنَعَ اللَّهُ، وَلاَ يَنْفَعُ ذَا الْجَدِّ مِنْهُ الْجَدُّ‏.‏ وَمَنْ يُرِدِ اللَّهُ بِهِ خَيْرًا يُفَقِّهْهُ فِي الدِّينِ، سَمِعْتُ هَؤُلاَءِ الْكَلِمَاتِ مِنَ النَّبِيِّ صلى الله عليه وسلم عَلَى هَذِهِ الأعْوَادِ‏.‏

References2 variants
In-Book Reference
Book 31, Hadith 63
English Reference
Book 31, Hadith 666