You are sorting the formulas as well as the data, so their references are moving as well. This will always happen when sorting formulas as far as I am aware, unless you convert to a multi-cell array formula