View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Conan Kelly Conan Kelly is offline
external usenet poster
 
Posts: 419
Default Programming SendKeys

Hello all,

I have 20+ cells with fomulas relative to the following formula:

=SUM('Totals Inputs'!BH15:BJ15)-K15

I want to select the part that reads "'Totals Inputs'!BH15:BJ15" and hit the
[F9] key to replace the reference with the values in these 3 cells. I want
to do this for each cell, replacing the references relative to the one
given.

I tried using the following code to recreate the key sequence that would
accomplish this:





Sub testing()
Dim prngCell As Range

For Each prngCell In Selection.Cells
'prngCell.Activate
Application.SendKeys "{F2}", True
Application.SendKeys "^{RIGHT}", True
Application.SendKeys "{RIGHT}", True
Application.SendKeys "{RIGHT}", True
Application.SendKeys "+^{RIGHT}", True
Application.SendKeys "+^{RIGHT}", True
Application.SendKeys "+^{RIGHT}", True
Application.SendKeys "+^{RIGHT}", True
Application.SendKeys "{F9}", True
Application.SendKeys "{ENTER}", True
Next prngCell
End Sub





The results: XL ended up calculating the whole formula instead of just the
one reference (or it replaced the formula with the value).

I can't step through this code because the SendKeys command will go to the
VBE instead of XL.

Is this possible to do?

Thanks for any help anyone can provide,

Conan Kelly