i'm using this code for sorting (checked for Excel 2010/2013):
Worksheets("Tabelle4(1)").Activate
ActiveSheet.Sort.SortFields.Add Key:=Range( _
"W2:W51"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
I loop over a sheet 70 times with different values and sort and export them as a pdf. Everything works fine, but after approximately 30 times I get an error 1004. If I start the loop at this point 30 again it works fine. The problem doesn't seem to do with the values. Is there a buffer inside of excel, which I've to clear from time to time?