(Solved) – Send Keys to update cells referenced in Array

  • by

I have a hard coded formula in some cells that are only updated upon pressing enter in the cells.

I would like this macro to “click into the cell and press enter” to update the value and cause the formula to return a value.

I have two macros, one that updates one specific cell, and another that I want to update an array of cell references. For some reason, only the one cell macro works. Does anyone know why? I would like this to be potentially used across multiple sheets and multiple rows/columns

One Cell:

Private Sub One_Cell_Click()

Application.SendKeys "{F2}"
Application.SendKeys "{ENTER}"

End Sub

Multiple Cells

Private Sub All_Cells_Click()
Dim cellUpdates(0 To 3) As Variant
Dim cell As Variant

cellUpdates(0) = "$D$3"
cellUpdates(1) = "$D$4"
cellUpdates(2) = "$G$5"
cellUpdates(3) = "$Y$6"

For Each cell In cellUpdates

Application.SendKeys "{F2}"
Application.SendKeys "{ENTER}"
Next cell

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *