Note: The other languages of the website are Google-translated. Back to English
Masuk  \/ 
x
or
x
Daftar  \/ 
x

or

Bagaimana cara mengklik dua kali sel dan menambahkan 1 ke nilai sel itu di Excel?

Artikel ini akan menunjukkan kepada Anda metode menambahkan 1 ke nilai sel secara otomatis dengan mengklik dua kali di Excel.

Klik dua kali sel dan tambahkan 1 dengan kode VBA


Klik dua kali sel dan tambahkan 1 dengan kode VBA


Kode VBA berikut dapat membantu Anda menambahkan 1 ke nilai sel setelah mengklik ganda. Silakan lakukan sebagai berikut.

1. Klik kanan tab lembar yang nilai selnya perlu Anda tambahkan 1 dengan mengklik ganda. Lalu klik Lihat kode dari menu klik kanan.

2. Dalam bermunculan Microsoft Visual Basic untuk Aplikasi jendela, salin dan tempel kode VBA di bawah ini ke jendela Kode.

Kode VBA: Tambahkan 1 ke nilai sel dengan mengklik ganda

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

Catatan: Dalam kode, A1 adalah sel yang akan Anda tambahkan nomor 1 dengan mengklik ganda.

3. tekan lain + Q secara bersamaan untuk menutup jendela Microsoft Visual Basic for Applications.

Sekarang, klik dua kali pada sel A1 akan menambahkan 1 ke nilai yang ada seperti gambar di bawah ini.


Terkait artikel:


Alat Produktivitas Kantor Terbaik

Kutools for Excel Memecahkan Sebagian Besar Masalah Anda, dan Meningkatkan Produktivitas Anda hingga 80%

  • Reuse: Masukkan dengan cepat rumus, bagan yang kompleks dan apa pun yang pernah Anda gunakan sebelumnya; Enkripsi Sel dengan kata sandi; Buat Milis dan mengirim email ...
  • Super Formula Bar (dengan mudah mengedit beberapa baris teks dan rumus); Membaca Tata Letak (membaca dan mengedit sel dalam jumlah besar dengan mudah); Tempel ke Rentang yang Difilter...
  • Gabungkan Sel / Baris / Kolom tanpa kehilangan Data; Pisahkan Konten Sel; Gabungkan Baris / Kolom Duplikat... Mencegah Sel Duplikat; Bandingkan Rentang...
  • Pilih Duplikat atau Unik Baris; Pilih Baris Kosong (semua sel kosong); Temukan Super dan Temukan Fuzzy di Banyak Buku Kerja; Pilih Acak ...
  • Salinan Tepat Beberapa Sel tanpa mengubah referensi rumus; Buat Referensi Otomatis ke Beberapa Lembar; Sisipkan Poin, Kotak Centang, dan lainnya ...
  • Ekstrak Teks, Tambahkan Teks, Hapus berdasarkan Posisi, Hapus Space; Membuat dan Mencetak Subtotal Paging; Konversi Konten Antar Sel dan Komentar...
  • Filter Super (simpan dan terapkan skema filter ke sheet lain); Penyortiran Lanjutan menurut bulan / minggu / hari, frekuensi dan lainnya; Filter Khusus dengan huruf tebal, miring ...
  • Gabungkan Workbooks dan WorkSheets; Gabungkan Tabel berdasarkan kolom kunci; Pisahkan Data menjadi Beberapa Lembar; Konversi Batch xls, xlsx dan PDF...
  • Lebih dari 300 fitur canggih. Mendukung Office / Excel 2007-2019 dan 365. Mendukung semua bahasa. Penerapan yang mudah di perusahaan atau organisasi Anda. Fitur lengkap uji coba gratis 30 hari. Jaminan uang kembali 60 hari.
tab kte 201905

Tab Office Membawa antarmuka Tab ke Office, dan Membuat Pekerjaan Anda Jauh Lebih Mudah

  • Aktifkan pengeditan dan pembacaan tab di Word, Excel, PowerPoint, Publisher, Access, Visio, dan Project.
  • Buka dan buat banyak dokumen di tab baru di jendela yang sama, bukan di jendela baru.
  • Tingkatkan produktivitas Anda hingga 50%, dan kurangi ratusan klik mouse untuk Anda setiap hari!
officetab bawah
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    OW · 8 months ago
    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?
  • To post as a guest, your comment is unpublished.
    Stella · 1 years ago
    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
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      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
  • To post as a guest, your comment is unpublished.
    Bill · 3 years ago
    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
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Bill,
      Thank you for sharing.
      • To post as a guest, your comment is unpublished.
        BB · 3 years ago
        Thank You! that helped me a lot!
  • To post as a guest, your comment is unpublished.
    Steve · 3 years ago
    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.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Sorry I didn’t get your point.
      • To post as a guest, your comment is unpublished.
        Adam · 3 years ago
        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?
        • To post as a guest, your comment is unpublished.
          laura · 3 years ago
          maybe by making a table with a range name. and updating the formula to include that?
        • To post as a guest, your comment is unpublished.
          Steve · 3 years ago
          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
          • To post as a guest, your comment is unpublished.
            Sophie · 3 years ago
            This code does not seem to work for me. Don't I have to specify which is the Target.Adress ?
          • To post as a guest, your comment is unpublished.
            crystal · 3 years ago
            Dear Steve,
            I got your point finally, and thank you for sharing.
  • To post as a guest, your comment is unpublished.
    Matt · 3 years ago
    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)
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      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.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      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.