In 1822, he served in the office of high sheriff; he was dismissed as a result of involvement in the dealings of Charles Douglass Smith.
[3] On the repeal of the Corn Laws, MacGregor gave up his post at the Board of Trade, and entered parliamentary politics, He was elected as a Whig Member of Parliament for Glasgow in July 1847, resigning in 1857 shortly before his death, by becoming Steward of the Manor of Northstead.
Though it was far from prosperous, he shamelessly puffed it, in a chapter on "Banking" contributed to Edwin Troxell Freedley's Money in 1853.
In 1830 he made a tour on the continent of Europe, and published a travel book based on it, My Note-book (1835), London, 3 vols.
With his friend James Deacon Hume, he projected in 1832 a major work on international commercial statistics.
[3] During his tenure of office he made 22 parliamentary statistical reports, in Commercial Tariffs and Regulations of the several States of Europe and America, together with the Commercial Treaties between England and Foreign Countries, published, with appendix, in 8 vols., London, 1841–50; and in A Digest of the Productive Resources, Commercial Legislation, Customs Tariffs, Navigation, Port and Quarantine Laws and Charges, Shipping, Imports and Exports, and the Monies, Weights, and Measures of all Nations, including all British Commercial Treaties with Foreign States, collected from Authentic Records, and consolidated with especial reference to British and Foreign Products, Trade, and Navigation, London, 1844–8, 3 vols.