in reply to Help with formula in excel

You have the following piece of code, where I guess you want $Lastrow3 to be interpolated but, since it is inside a single-quote, it doesn't.
$Sheet->Range("H$lastrow4")->{Formula} = '=sum("H17:H.$Lastrow3")';
Try changing it to the following
$Sheet->Range("H$lastrow4")->{Formula} = '=sum("H17:H.'.$Lastrow3.'")' +;