Today encountered a magical problem, has been using a very good code suddenly error: "Class range AutoFill method Invalid", search on the internet, feel no one with the same situation I encountered. Debug, look at the code, found in the program, the AutoFill is specified before and after the same area. I do not know whether it is for this reason, can only manually test what the situation will produce this hint.
Wrote a test code:
Worksheet sheet = helper.getactivesheet (); = Sheet. cells[11]; = Sheet. cells[31]; = sheet. Range[b, end]; 1; B.autofill (A, xlautofilltype.xlfillseries);
The above code can be executed successfully.
Modify the test code above to see what the situation would be to report a similar error. Modify the last line to:
A.autofill (A, xlautofilltype.xlfillseries);
This time the code error, and I encountered a similar situation, will it be because the area A is too large to contain? Then try again and change the code to:
B.autofill (b, xlautofilltype.xlfillseries);
Actually also reported wrong. OK, you can confirm it. Range1.autofill (range2,*), Range2 to contain Range1, two regions cannot be identical.
Excel uses autofill hint "AutoFill method for class range is invalid"