If Paul hasn't sorted it for you (I didn't see much wrong with the code and since it's guaranteed to fail if the value in A1 isn't one of the values in the pivot table, but you say it used to work, I didn't look hard) then supply a file without a load of errors in.
Personally, instead of cell A1, I'd add a slicer to the pivot for that field, then move it near cell A1.