The last rakes were retained until about 2008 or so when Stirling - Alloa - Kincardine reopened to allow coal traffic for Hunterston to be diverted away from the Forth Bridge which was route barred to the larger replacement wagons and I think until maybe 2010 or so once Hope Cement Works could start accepting HTA wagons with it's coal deliveries? I distinctly remember the former being a big thing in the railway press but the latter I'm less sure of.
That's correct regarding the Hope Cement works traffic: According to 'Merry-Go-Round On The Rails' by David Monk-Steel, two sets of HAAs were retained until summer 2010 to work up to three trains per week to Hope from the Ayrshire opencast sites, and were the last regular working for the wagons.
The most recent photos I have of HAA wagons within Hope works were taken during summer 2009, seen in the background in the photo below.
Again according to 'Merry-Go-Round On The Rails', there were a total of 11,162 wagons, including variations on the basic design, built. By 2009, as the final flows to use these wagons were switching to HTA bogie hopper operation, there were 1,185 still in stock of the following types:
HAA: 765 (Standard design - 10702 built as noted above)
HBA: 3 (HDA hoppers fitted with canopies)
HCA: 9 (HAA hoppers fitted with canopies)
HDA: 49 (Improved braking capability, permitted to run at 60mph - 460 built)
HFA: 36 (HAA hoppers fitted with modified canopies)
HMA: 318 (Hoppers fitted with modified brakes)
HNA: 5 (Hoppers fitted with modified brakes and canopies)