It is not the fact that a man has riches which keeps him from the Kingdom of Heaven, but the fact that riches have him.
John Caird (1820-1898) Scottish theologian, academic, preacher
(Attributed)
I am unable to find the source of this quotation amongst Caird's writings (including of his many sermons). While he preaches in places on money and riches (e.g., "Covetousness a Misdirected Worship"), these phrases or ones like them do not show up in his works that I can find.
Nevertheless, this quotation was popularly requoted in the late 19th and early 20th centuries, beginning during Caird's lifetime. The earliest references I find are from 1878 --
The Pacific, Vol. 27, No. 17/1366 (1878-04-25) and (in quotations marks rather than italics) The Calcutta Indian Mirror (1879-05-18):Dr. Caird says it is not the fact that a man has riches which keeps him from the kingdom of heaven, but the fact that riches have him.
Christian Pioneer Magazine, "Gems," Vol. 23 (1878) and The Raleigh Christian Advocate (1879-02-05):It is not the fact that a man has riches which keeps him from the kingdom of heaven, but the fact that riches have him.
-- Dr. Caird
Even this point, the references are not to a story about Caird preaching or writing it, but column filler, indicating the quote was already in wide circulation. The use of quotes / italics suggests it might also be an excerpt from a more complex formulation.
By the turn of the century, the quote is fixed as above, and gains popularity in various quotation collections, including Hotchkiss, ed., Dictionary of Burning Words of Brilliant Writers (1895).
Citations for this phrase begin with attribution to "John Caird," "J. Caird," and "Dr. Caird," referencing the prominent Scottish theologian and preacher. After a time, only his last name is used. Starting mid-20th century (and as memory of John Caird fades), the attribution is often to David Caird (e.g., 1, 2, 3).