Search code examples
excelvba

Single click edit cell


I'm looking to see if I can get a function within my project where when you click a cell it goes straight to edit mode, rather than having to double click the cell, I know that F2 does this but id rather it be done when the user clicks the cell and its into edit mode without having to do anything else other than clicking the cell.

There are two cells I need this to be applied too, G3, and G4.

I've tried recording a macro but to no avail.


Solution

  • You double click on the applicable Sheet in the Project navigator:

    enter image description here

    And paste in the code

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Dim trigger As Range
        Set trigger = Range("G3:G4,A1:A2")
        If Not Application.Intersect(Target, trigger) Is Nothing Then SendKeys "{F2}"
    End Sub