Hoppa till huvudinnehåll

Hur aktiverar man celler för redigering med ett enda klick i Excel?

Den här artikeln talar om att aktivera celler för redigering med ett enda klick i Excel. Gör så här steg för steg.

Aktivera celler för redigering med ett enda klick med VBA-kod


Aktivera cell för redigering med enkelklickning med VBA-kod

Följande VBA-kod kan hjälpa dig att aktivera celler för redigering med ett enda klick.

1. Öppna kalkylbladet du behöver för att aktivera celler med ett enda klick. Högerklicka på arkfliken och klicka Visa kod från högerklickmenyn.

2. I öppningen Microsoft Visual Basic för applikationer , kopiera och klistra in nedanstående VBA-kod i Koda fönster.

VBA-kod: Aktivera cell för redigering med ett enda klick

#If Win64 Then
'Updated by Extendoffice 2018/2/2
    Private Declare PtrSafe Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    Private Declare PtrSafe Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
#Else
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
#End If
Const VK_NUMLOCK = 144
Const VK_CAPITAL = 20
Const VK_SCROLL = 145
Dim xOldNLState As Long
Dim xOldCLState As Long
Dim xOldSLState As Long
Const KEY_MASK As Integer = &HFF80 '

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If (GetKeyState(vbKeyShift) And KEY_MASK) <> 0 Then Exit Sub
    xOldNLState = GetAsyncKeyState(VK_NUMLOCK)
    xOldCLState = GetAsyncKeyState(VK_CAPITAL)
    xOldSLState = GetAsyncKeyState(VK_SCROLL)
    SendKeys "{F2}"
    If GetAsyncKeyState(VK_NUMLOCK) <> xOldNLState Then
        Application.SendKeys "{NUMLOCK}"
    End If
    If GetAsyncKeyState(VK_CAPITAL) <> xOldCLState Then
        Application.SendKeys "{CAPSLOCK}"
    End If
    If GetAsyncKeyState(VK_SCROLL) <> xOldSLState Then
        Application.SendKeys "{SCROLLLOCK}"
    End If
End Sub

3. tryck på andra + Q samtidigt för att stänga Microsoft Visual Basic för applikationer fönster.

Från och med nu, när ett klick på en cell i det aktuella kalkylbladet, aktiveras cellen omedelbart.

Bästa kontorsproduktivitetsverktyg

🤖 Kutools AI Aide: Revolutionera dataanalys baserat på: Intelligent utförande   |  Generera kod  |  Skapa anpassade formler  |  Analysera data och generera diagram  |  Anropa Kutools funktioner.
Populära funktioner: Hitta, markera eller identifiera dubbletter   |  Ta bort tomma rader   |  Kombinera kolumner eller celler utan att förlora data   |   Rund utan formel ...
Superuppslag: Flera kriterier VLookup    VLookup med flera värden  |   VSök över flera ark   |   Fuzzy Lookup ....
Avancerad rullgardinslista: Skapa snabbt en rullgardinslista   |  Beroende rullgardinslista   |  Flervals-rullgardinslista ....
Kolumnhanterare: Lägg till ett specifikt antal kolumner  |  Flytta kolumner  |  Växla synlighetsstatus för dolda kolumner  |  Jämför intervall och kolumner ...
Utvalda funktioner: Rutnätsfokus   |  Designvy   |   Stor formelbar    Arbetsbok & Bladhanterare   |  Resursbibliotek (Automatisk text)   |  Datumväljare   |  Kombinera arbetsblad   |  Kryptera/Dekryptera celler    Skicka e-postmeddelanden efter lista   |  Superfilter   |   Specialfilter (filtrera fet/kursiv/genomstruken...) ...
Topp 15 verktygssatser12 text verktyg (lägga till text, Ta bort tecken, ...)   |   50+ Diagram Typer (Gantt Chart, ...)   |   40+ Praktiskt Formler (Beräkna ålder baserat på födelsedag, ...)   |   19 Införande verktyg (Infoga QR-kod, Infoga bild från sökväg, ...)   |   12 Konvertering verktyg (Siffror till ord, Valutaväxling, ...)   |   7 Slå ihop och dela verktyg (Avancerade kombinera rader, Dela celler, ...)   |   ... och mer

Uppgradera dina Excel-färdigheter med Kutools för Excel och upplev effektivitet som aldrig förr. Kutools för Excel erbjuder över 300 avancerade funktioner för att öka produktiviteten och spara tid.  Klicka här för att få den funktion du behöver mest...

Beskrivning


Fliken Office ger ett flikgränssnitt till Office och gör ditt arbete mycket enklare

  • Aktivera flikredigering och läsning i Word, Excel, PowerPoint, Publisher, Access, Visio och Project.
  • Öppna och skapa flera dokument i nya flikar i samma fönster, snarare än i nya fönster.
  • Ökar din produktivitet med 50 % och minskar hundratals musklick för dig varje dag!
Comments (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
nice and understood
This comment was minimized by the moderator on the site
Is there a way to make it so that you can be in one program window an click into the window for excel and onto the cell in one click? I noticed, while it does go right to edit mode, it goes to the previous cell when you click into the program so that it still requires two clicks to start editing.
This comment was minimized by the moderator on the site
Sorry, not sure if my last post was published. Here it is again just in case:

Hey Everyone, first off, many thanks for posting this, it's a definite time saver. Just noticed that if you try to use the "Shift+tab" keyboard command to move one cell to the left, a comment box gets created instead. Anyway to fix this issue? Thanks!
This comment was minimized by the moderator on the site
Dear Wayne,
The code is now updated with the problem fixed. Thank you for your feedback.
This comment was minimized by the moderator on the site
Hey Everyone, first off, many thanks for posting this, it's a definite time saver. Just noticed that if you try to use the "Shift+tab" to move one cell to the left, a comment box gets created instead. Anyway to fix this issue? Thanks!
This comment was minimized by the moderator on the site
Hey guys. I had a question about a strange side effect this code does when I use it in one of my worksheets.
The code I tried was the one mentioned in the post.
//
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
SendKeys "{F2}"
End Sub
//
The side effect I'm getting is when I make a cell active my Numlock turns off/on.
Any help would be appreciated.
This comment was minimized by the moderator on the site
Good Day,
The code is updated with the problem solving. Thank you for your comment.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations