record a macro of you manually typing in the code, and then edit the macro (which will be VBA code). where you are typing, substitute the sendkey commands.

i think you'd be better off computing the formatted data into a cell, then setting it into a string, so that you could send the whole string at once.

I'm pretty sure that you can tell sendkeys to send a string, but I've only seen it used to send quoted text. Yup. You can. I just looked at an example that sent the numbers 1-100 to calculator to add up.

That should work well.