Excel VBA - SendKeys "{F2}" - keeps toggling num-lock

1.1k Views Asked by At

After using setting a cell to select and then using SendKeys "{F2}" (So that the cell is ready for input) it likes to toggle num-lock every time this is ran.

I have seen people say to use SendKeys "{NUMLOCK}", True after the SendKeys "{F2}" but tat did nto help. even tried adding Application.Wait Now + TimeValue("00:00:01") between the two comands, but it still keeps toggling.

I have also read its a bug with Excel/VBA.

Is there a better solutions? I need to select the cell and then force it into edit mode in order for some validation checks to work properly, else it bypasses the check if it just selects the cell, the could continue on, forcing it into edit make it so they have to make a change if not and they leave the cell the validation kicks in again.

I also found this code and tried, but that doe not work, it just keeps toggling

Dim wshshell As Object
Set wshshell = CreateObject("WScript.Shell")
wshshell.SendKeys "{NUMLOCK}"
Set wshshell = Nothing

Even tried this and replaced with F2 but it still toggled numlock.

I need numlock to stay on at all times. is there another way to invoke the edit cell instead of F2?

0

There are 0 best solutions below