Loncat ke daftar isi utama

Bagaimana cara mengubah nilai sel dengan mengklik sel?

Apakah mungkin bagi kami untuk mengubah nilai sel dengan mengklik sel di Excel? Misalnya, saat Anda mengklik sel A1 tertentu, pertama kali, teks "Excel" akan ditampilkan, jika Anda mengklik A1 lagi, teks "Word" ditampilkan, dan teks "Outlook" ditampilkan saat Anda mengklik ini sel untuk ketiga kalinya. Dalam kasus ini, nilai di sel A1 akan berulang dari "Excel" ke "Word" ke "Outlook" ke "Excel" …… seperti gambar berikut yang ditampilkan:

doc mengubah nilai dengan klik 1

Ubah nilai sel dengan mengklik sel dengan kode VBA


panah gelembung kanan biru Ubah nilai sel dengan mengklik sel dengan kode VBA

Untuk menyelesaikan tugas ini di Excel, kode VBA berikut dapat membantu Anda, lakukan hal berikut:

1. Klik kanan tab lembar yang ingin Anda ubah nilai selnya dengan mengkliknya, lalu pilih Lihat kode dari menu konteks, dan di buka Microsoft Visual Basic untuk Aplikasi jendela, salin dan tempel kode berikut ke dalam Modul kosong:

Kode VBA: Ubah nilai sel dengan mengklik sel:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
'Updateby Extendoffice
  Application.EnableEvents = False
  With Target
  If .Address = Range("A1").Address Then
    Select Case .Value
      Case "Excel"
        .Value = "Word"
      Case "Word"
        .Value = "Outlook"
      Case "Outlook"
        .Value = "Excel"
      Case Else
        .Value = "Word"
    End Select
  End If
  End With
  Range("A2").Select
  Application.EnableEvents = True
End Sub

doc mengubah nilai dengan klik 2

Note: Pada kode di atas, A1 adalah sel tempat Anda ingin mengubah nilai dengan mengklik, "Excel","Word","Outlook"Adalah nilai sel yang ingin Anda tampilkan berulang kali, Anda dapat mengubahnya sesuai kebutuhan Anda.

2. Setelah menempelkan kode, kemudian simpan kode tersebut dan tutup jendela. Sekarang, ketika Anda mengklik sel A1 pertama kali, teks "Excel" ditampilkan sekaligus, klik lagi, teks "Word" muncul, teks "Outlook" ditampilkan jika Anda mengkliknya untuk ketiga kalinya, lihat tangkapan layar:

doc mengubah nilai dengan klik 1


Artikel terkait lainnya:

Bagaimana cara memfilter data hanya dengan mengklik konten sel di Excel?

Bagaimana cara mengurutkan data kolom dengan mengklik header di Excel?

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 (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This is great information, thanks for everyone's input! Is there away to apply this same type of approach with a lookup or index\match value?

For example, if I click on a value in A1, can the VBA be configured to index that value in another worksheet column, and display a matched value in B1? Thank you again!
This comment was minimized by the moderator on the site
I am trying to apply this to an entire column of individual cells, not just one cell. Is this possible? When I change the range from "A1" to "A1:A100" nothing happens when I click the cells in that range.
This comment was minimized by the moderator on the site
This is the final code that worked for me.  I use it to check a cell when an item is completed.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Application.EnableEvents = False
    With Target
      Dim KeyCells As Range
      Set KeyCells = Range("D6:D8000")
      If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
        Select Case .Value
          Case "ü"
            .Value = ""
          Case ""
            .Value = "ü"
        End Select
      End If
    End With
  Application.EnableEvents = True
End Sub
This comment was minimized by the moderator on the site
You can do that by declaring the range you want to have as KeyCells and than put that into the Application.Intersection Method. This will let you change the Value of your choice from all the cells. Worked for me but i am bad at explaining ^^


Application.EnableEvents = False
With Target


Dim KeyCells as Range

Set KeyCells = Range("A1:A100")

If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then

Select Case .Value

...
This comment was minimized by the moderator on the site
You can do that by declaring the range you want to have as KeyCells and than put that into the Application.Intersection Method. This will let you change the Value of your choice from all the cells. Worked for me but i am bad at explaining ^^

Dim KeyCells as Range

Set KeyCells = Range("A1:A100")

If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then

Select Case .Value

...
This comment was minimized by the moderator on the site
I did it but i will not tell anyone MUWAHAHAHAHAHAHAHAHAHA
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations