I would like to do a polynomial curve fitting to my data. I found a Trend worksheetfunction can do the job. However, I've never made it work in my VB macro. I was passing two range values (range.value) into the function just like the example in MSDN. The first range contains the y values, and the second range contains a nx3 matrix. The first column of second range contains x values; second column contains x^2 values, and the third column contains x^3 values. I expected to get the same result as I tried in cells. However, I always got 'Type Mismatch' error back when executing this statement. Could anyone tell me how to use this function in VB macro, if I want to do a polynomial fit with f(x^3)? Or is there any other way to do curve fitting? Thanks a lot.