Μετάβαση στο κύριο περιεχόμενο

Πώς να κάνετε διπλό κλικ σε ένα κελί και να προσθέσετε 1 σε αυτήν την τιμή κελιού στο Excel;

Αυτό το άρθρο θα σας δείξει τη μέθοδο προσθήκης 1 σε μια τιμή κελιού αυτόματα με διπλό κλικ σε αυτήν στο Excel.

Κάντε διπλό κλικ σε ένα κελί και προσθέστε 1 με τον κωδικό VBA


Κάντε διπλό κλικ σε ένα κελί και προσθέστε 1 με τον κωδικό VBA

Ο ακόλουθος κωδικός VBA μπορεί να σας βοηθήσει να προσθέσετε 1 σε μια τιμή κελιού μετά από διπλό κλικ. Κάντε τα εξής:

1. Κάντε δεξί κλικ στην καρτέλα φύλλου στην οποία οι τιμές του κελιού πρέπει να προσθέσετε 1 με διπλό κλικ. Στη συνέχεια κάντε κλικ Προβολή κωδικού από το μενού με δεξί κλικ.

2. Στο αναδυόμενο παράθυρο Microsoft Visual Basic για εφαρμογές παράθυρο, αντιγράψτε και επικολλήστε τον παρακάτω κώδικα VBA στο παράθυρο Code.

Κωδικός VBA: Προσθέστε 1 σε μια τιμή κελιού με διπλό κλικ

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    If Not Intersect(Target, Range("A1")) Is Nothing Then
      Range("A1").Value = Range("A1").Value + 1
      Cancel = True
    End If
End Sub

Note: Στον κώδικα, το Α1 είναι το κελί στο οποίο θα προσθέσετε τον αριθμό 1 με διπλό κλικ.

3. Πάτα το άλλος + Q ταυτόχρονα για να κλείσετε το παράθυρο της Microsoft Visual Basic for Applications.

Τώρα, κάντε διπλό κλικ στο κελί A1 θα προσθέσει 1 στην υπάρχουσα τιμή όπως φαίνεται στο παρακάτω στιγμιότυπο οθόνης.


Σχετικά Άρθρα:

Τα καλύτερα εργαλεία παραγωγικότητας γραφείου

🤖 Kutools AI Aide: Επανάσταση στην ανάλυση δεδομένων με βάση: Ευφυής Εκτέλεση   |  Δημιουργία κώδικα  |  Δημιουργία προσαρμοσμένων τύπων  |  Αναλύστε δεδομένα και δημιουργήστε γραφήματα  |  Επίκληση Λειτουργιών Kutools...
Δημοφιλή χαρακτηριστικά: Εύρεση, επισήμανση ή αναγνώριση διπλότυπων   |  Διαγραφή κενών γραμμών   |  Συνδυάστε στήλες ή κελιά χωρίς απώλεια δεδομένων   |   Γύρος χωρίς φόρμουλα ...
Σούπερ Αναζήτηση: VLookup πολλαπλών κριτηρίων    VLookup πολλαπλών τιμών  |   VLookup σε πολλά φύλλα   |   Ασαφής αναζήτηση ....
Σύνθετη αναπτυσσόμενη λίστα: Γρήγορη δημιουργία αναπτυσσόμενης λίστας   |  Εξαρτημένη αναπτυσσόμενη λίστα   |  Πολλαπλή αναπτυσσόμενη λίστα ....
Διαχειριστής στήλης: Προσθέστε έναν συγκεκριμένο αριθμό στηλών  |  Μετακίνηση στηλών  |  Εναλλαγή κατάστασης ορατότητας κρυφών στηλών  |  Συγκρίνετε εύρη και στήλες ...
Επιλεγμένα Χαρακτηριστικά: Εστίαση πλέγματος   |  Προβολή σχεδίου   |   Μεγάλη Formula Bar    Διαχείριση βιβλίου εργασίας & φύλλου   |  Βιβλιοθήκη πόρων (Αυτόματο κείμενο)   |  Επιλογή ημερομηνίας   |  Συνδυάστε φύλλα εργασίας   |  Κρυπτογράφηση/Αποκρυπτογράφηση κελιών    Αποστολή email ανά λίστα   |  Σούπερ φίλτρο   |   Ειδικό φίλτρο (φίλτρο με έντονη γραφή/πλάγια γραφή/διαγραφή...) ...
Κορυφαία 15 σύνολα εργαλείων12 Κείμενο Εργαλεία (Προσθήκη κειμένου, Κατάργηση χαρακτήρων, ...)   |   50 + Διάγραμμα Τύποι (Gantt διάγραμμα, ...)   |   40+ Πρακτικό ΜΑΘΗΜΑΤΙΚΟΙ τυποι (Υπολογίστε την ηλικία με βάση τα γενέθλια, ...)   |   19 Εισαγωγή Εργαλεία (Εισαγωγή κωδικού QR, Εισαγωγή εικόνας από το μονοπάτι, ...)   |   12 Μετατροπή Εργαλεία (Αριθμοί σε λέξεις, Μετατροπή Συναλλάγματος, ...)   |   7 Συγχώνευση & διαχωρισμός Εργαλεία (Σύνθετες σειρές συνδυασμού, Διαίρεση κελιών, ...)   |   ... κι αλλα

Αυξήστε τις δεξιότητές σας στο Excel με τα Kutools για Excel και απολαύστε την αποτελεσματικότητα όπως ποτέ πριν. Το Kutools για Excel προσφέρει πάνω από 300 προηγμένες δυνατότητες για την ενίσχυση της παραγωγικότητας και την εξοικονόμηση χρόνου.  Κάντε κλικ εδώ για να αποκτήσετε τη δυνατότητα που χρειάζεστε περισσότερο...

Περιγραφή


Το Office Tab φέρνει τη διεπαφή με καρτέλες στο Office και κάνει την εργασία σας πολύ πιο εύκολη

  • Ενεργοποίηση επεξεργασίας και ανάγνωσης καρτελών σε Word, Excel, PowerPoint, Publisher, Access, Visio και Project.
  • Ανοίξτε και δημιουργήστε πολλά έγγραφα σε νέες καρτέλες του ίδιου παραθύρου και όχι σε νέα παράθυρα.
  • Αυξάνει την παραγωγικότητά σας κατά 50% και μειώνει εκατοντάδες κλικ του ποντικιού για εσάς κάθε μέρα!
Comments (17)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
how can i answer by YES or NO by adding check mark?
This comment was minimized by the moderator on the site
What code would I you if I want to add 1 to multiple cells lets say E5:E15 but then add .5 or a different number to another group of cells like G5:515?
This comment was minimized by the moderator on the site
I cannot get this to work in multiple cells
Tried using, but it did not work


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
If Not Intersect(Target, Range("B2:L14")) Is Nothing Then
Range("B2:L14").Value = Range("B2:L14").Value + 1
Cancel = True
End If
End Sub
This comment was minimized by the moderator on the site
Hi Stella,
Please apply the below VBA to solve the problem.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

On Error Resume Next

If Not Intersect(Target, Range("B2:L14")) Is Nothing Then

Target.Value = Target.Value + 1

Cancel = True

End If

End Sub
This comment was minimized by the moderator on the site
If you want to increment any cell in a workbook cell by double clicking on that cell but only that cell, this code works:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
If Not Intersect(Target, Range(ActiveCell.Address)) Is Nothing Then
ActiveCell.Value = ActiveCell.Value + 1
Cancel = True
End If
End Sub
This comment was minimized by the moderator on the site
Dear Bill,
Thank you for sharing.
This comment was minimized by the moderator on the site
Thank You! that helped me a lot!
This comment was minimized by the moderator on the site
This is great! How do I do this for multiple cells? I type in "A1,A2" instead "A1", it makes both cells equal and adds 1 to both cells simultaneously. I'd like the cells to act independently.
This comment was minimized by the moderator on the site
Sorry I didn’t get your point.
This comment was minimized by the moderator on the site
Hello - agree with Steve this is great. I think what he would like (and me too) is to be able to add to the value of multiple different cells in the same tab by double clicking on them. He has amended the VBA formula so it says "A1,A2" instead of just "A1" however double clicking on "A1" adds 1 to both cells. Is it possible to change the formula so that multiple cells are included with the value of each only being increased when you click on it directly?
This comment was minimized by the moderator on the site
maybe by making a table with a range name. and updating the formula to include that?
This comment was minimized by the moderator on the site
Basically, with the code above, if you double clicked on A1, it would add 1 to A1. If I changed A1 to A1:A2 in the Target Range, then if I double clicked on A1 or A2, it would add 1 to A1. What I wanted was to add 1 to A1 only if I double clicked on A1, and add 1 to A2 only if I double clicked on A2. I also did not want to add 1 to both cells.

I think I have found what I was looking for:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("D5:BC56")) Is Nothing Then
Cancel = True
Range(Target.Address).Value = Val(Range(Target.Address).Value) + 1
End If
End Sub
This comment was minimized by the moderator on the site
This code does not seem to work for me. Don't I have to specify which is the Target.Adress ?
This comment was minimized by the moderator on the site
Dear Steve,
I got your point finally, and thank you for sharing.
This comment was minimized by the moderator on the site
Can we add a two digit number to the end of the date? for example i need to double click and add the current date and the next two digit number (20171030-01 then the next cell will show 20171030-02 upon double click)
This comment was minimized by the moderator on the site
Dear Matt,
The code only supports the number format cell. It can't work as your data 20171030-01 is text format. Sorry about that.
This comment was minimized by the moderator on the site
Dear Matt,
The code only supports the number format cell. It can work as your data 20171030-01 is a text format. Sorry about that.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations