Loncat ke daftar isi utama

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

Note: 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 AI Ajudan: Merevolusi analisis data berdasarkan: Eksekusi Cerdas   |  Hasilkan Kode  |  Buat Rumus Khusus  |  Analisis Data dan Hasilkan Grafik  |  Aktifkan Fungsi Kutools...
Fitur Populer: Temukan, Sorot, atau Identifikasi Duplikat   |  Hapus Baris Kosong   |  Gabungkan Kolom atau Sel tanpa Kehilangan Data   |   Putaran tanpa Formula ...
Pencarian Super: VLookup Beberapa Kriteria    VLookup Nilai Berganda  |   VLookup di Beberapa Lembar   |   Pencarian Fuzzy ....
Daftar Drop-down Lanjutan: Buat Daftar Drop Down dengan Cepat   |  Daftar Drop Down yang Bergantung   |  Multi-pilih Drop Down List ....
Manajer Kolom: Tambahkan Jumlah Kolom Tertentu  |  Pindahkan Kolom  |  Alihkan Status Visibilitas Kolom Tersembunyi  |  Bandingkan Rentang & Kolom ...
Fitur Unggulan: Fokus Kisi   |  Tampilan Desain   |   Bar Formula Besar    Manajer Buku Kerja & Lembar   |  Perpustakaan Sumberdaya (Teks otomatis)   |  Pemetik tanggal   |  Gabungkan Lembar Kerja   |  Enkripsi/Dekripsi Sel    Kirim Email berdasarkan Daftar   |  Filter Super   |   Filter Khusus (filter tebal/miring/coret...) ...
15 Perangkat Teratas12 Teks Tools (Tambahkan Teks, Hapus Karakter, ...)   |   50 + Grafik jenis (Gantt Chart, ...)   |   40+ Praktis Rumus (Hitung usia berdasarkan ulang tahun, ...)   |   19 Insersi Tools (Masukkan Kode QR, Sisipkan Gambar dari Jalur, ...)   |   12 Konversi Tools (Angka ke Kata, Konversi Mata Uang, ...)   |   7 Gabungkan & Pisahkan Tools (Lanjutan Gabungkan Baris, Pisahkan Sel, ...)   |   ... dan banyak lagi

Tingkatkan Keterampilan Excel Anda dengan Kutools for Excel, dan Rasakan Efisiensi yang Belum Pernah Ada Sebelumnya. Kutools for Excel Menawarkan Lebih dari 300 Fitur Lanjutan untuk Meningkatkan Produktivitas dan Menghemat Waktu.  Klik Di Sini untuk Mendapatkan Fitur yang Paling Anda Butuhkan...

Deskripsi Produk


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.
  • Meningkatkan produktivitas Anda sebesar 50%, dan mengurangi ratusan klik mouse untuk Anda setiap hari!
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鈥檛 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