Loncat ke daftar isi utama

Bagaimana cara menyorot sel atau baris dengan kotak centang di Excel?

Seperti gambar di bawah ini yang ditampilkan, Anda perlu menyorot baris atau sel dengan kotak centang. Saat kotak centang dicentang, baris atau sel tertentu akan disorot secara otomatis. Tapi bagaimana cara mencapainya di Excel? Artikel ini akan menunjukkan dua metode untuk mencapainya.

Sorot sel atau baris dengan kotak centang dengan Pemformatan Bersyarat
Sorot sel atau baris dengan kotak centang dengan kode VBA


Sorot sel atau baris dengan kotak centang dengan Pemformatan Bersyarat

Anda dapat membuat aturan Pemformatan Bersyarat untuk menyorot sel atau baris dengan kotak centang di Excel. Silakan lakukan sebagai berikut.

Tautkan semua kotak centang ke sel tertentu

1. Anda perlu memasukkan kotak centang ke dalam sel satu per satu secara manual dengan mengklik Pengembang > Menyisipkan > Kotak cek (Kontrol Formulir).

2. Sekarang kotak centang telah disisipkan ke sel di kolom I. Pilih kotak centang pertama di I1, masukkan rumus = $ J1 ke dalam bilah rumus, lalu tekan Enter kunci.

jenis: Jika Anda tidak ingin memiliki nilai yang terkait di sel yang berdekatan dengan kotak centang, Anda dapat menautkan kotak centang ke sel lembar kerja lain seperti = Sheet3! $ E1.

2. Ulangi langkah 1 sampai semua kotak centang ditautkan ke sel atau sel yang berdekatan di lembar kerja lain.
Note: Semua sel yang ditautkan harus berurutan dan terletak di kolom yang sama.

Buat aturan Pemformatan Bersyarat

Sekarang Anda perlu membuat aturan Pemformatan Bersyarat sebagai berikut langkah demi langkah.

1. Pilih baris yang perlu Anda sorot dengan kotak centang, lalu klik Format Bersyarat > Aturan baru bawah Beranda tab. Lihat tangkapan layar:

2. Dalam Aturan Pemformatan Baru kotak dialog, Anda perlu:

2.1 Pilih Gunakan rumus untuk menentukan sel mana yang akan diformat pilihan dalam Pilih Jenis Aturan kotak;

2.2 Memasukkan rumus = JIKA ($ J1 = BENAR, BENAR, SALAH) ke dalam Memformat nilai yang rumus ini benar kotak;
      Or = JIKA (Sheet3! $ E1 = BENAR, BENAR, SALAH) jika kotak centang ditautkan ke lembar kerja lain.

2.3 Klik tombol dibentuk tombol untuk menentukan warna yang disorot untuk baris;

2.4 Klik tombol OK tombol. Lihat tangkapan layar:

Note: Dalam rumusnya, $ J1 or $ E1 adalah sel tertaut pertama untuk kotak centang, dan pastikan referensi sel telah diubah menjadi absolut kolom (J1> $ J1 or E1> $ E1).

Sekarang aturan Conditional Formatting dibuat. Saat mencentang kotak centang, baris yang sesuai akan disorot secara otomatis saat screenshot bellow ditampilkan.


Sorot sel atau baris dengan kotak centang dengan kode VBA

Kode VBA berikut juga dapat membantu Anda menyorot sel atau baris dengan kotak centang di Excel. Silakan lakukan sebagai berikut.

1. Pada lembar kerja Anda perlu menyorot sel atau baris dengan kotak centang. Klik kanan file Tab Lembar dan pilih Lihat kode dari menu klik kanan untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Kemudian salin dan tempel kode VBA di bawah ini ke jendela Kode.

Kode VBA: Sorot baris dengan kotak centang di Excel

Sub AddCheckBox()
Dim xCell As Range
Dim xRng As Range
Dim I As Integer
Dim xChk As CheckBox
On Error Resume Next
InputC:
    Set xRng = Application.InputBox("Please select the column range to insert checkboxes:", "Kutools for Excel", Selection.Address, , , , , 8)
If xRng Is Nothing Then Exit Sub
If xRng.Columns.Count > 1 Then
    MsgBox "The selected range should be a single column", vbInformation, "Kutools fro Excel"
    GoTo InputC
Else
    If xRng.Columns.Count = 1 Then
        For Each xCell In xRng        
            With ActiveSheet.CheckBoxes.Add(xCell.Left, _
               xCell.Top, xCell.Width = 15, xCell.Height = 12)
               .LinkedCell = xCell.Offset(, 1).Address(External:=False)
               .Interior.ColorIndex = xlNone
               .Caption = ""
               .Name = "Check Box " & xCell.Row
            End With    
            xRng.Rows(xCell.Row).Interior.ColorIndex = xlNone                  
        Next        
    End If    
    With xRng    
     .Rows.RowHeight = 16    
    End With   
    xRng.ColumnWidth = 5#    
    xRng.Cells(1, 1).Offset(0, 1).Select    
    For Each xChk In ActiveSheet.CheckBoxes   
      xChk.OnAction = ActiveSheet.Name + ".InsertBgColor"      
    Next
End If
End Sub

Sub InsertBgColor()
Dim xName As Integer
Dim xChk As CheckBox
For Each xChk In ActiveSheet.CheckBoxes 
  xName = Right(xChk.Name, Len(xChk.Name) - 10) 
  If (xName = Range(xChk.LinkedCell).Row) Then   
   If (Range(xChk.LinkedCell) = "True") Then   
    Range("A" & xName, Range(xChk.LinkedCell).Offset(0, -2)).Interior.ColorIndex = 6    
   Else    
    Range("A" & xName, Range(xChk.LinkedCell).Offset(0, -2)).Interior.ColorIndex = xlNone  
   End If  
  End If
Next
End Sub

3. tekan F5 kunci untuk menjalankan kode. (Note: Anda harus meletakkan kursor ke bagian pertama kode untuk menerapkan tombol F5) di popping up Kutools untuk Excel kotak dialog, pilih kisaran yang ingin Anda sisipkan kotak centang, dan kemudian klik OK tombol. Di sini saya memilih rentang I1: I6. Lihat tangkapan layar:

4. Kemudian kotak centang dimasukkan ke dalam sel yang dipilih. Centang salah satu kotak centang, baris yang sesuai akan disorot secara otomatis 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 (3)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This is a horrendous article. It lacks a lot of information and steps. If you follow this article verbatim it will not end in the result you are seeking.

Essentially the article is saying to have 2 columns where the checkboxes are linked to adjacent columns to enter in values which are then used for conditional formats. No one wants to have values associated in adjacent cells to checkboxes. Lastly, if this is the route you're going you're not linking checkboxes to conditional formats, you are linking checkboxes to cell values which are then in turn associated to conditional formats.

It is easier to just use icons instead of checkboxes (use the green checkmark icon) and create the conditional formats for a value of 1 or 0. If cell = 1 then it will replace the value with the icon and highlight your row. To accomplish this you use 2 conditional formats on your table.

Top left of table is B4, bottom right of table is L28

1st conditional format:
USE A FORMULA TO DETERMINE WHICH CELLS TO FORMAT
Formula: =$B4=1
Format: fill
Applies to: =$B4:$L28

2nd conditional format:
FORMAT CELLS BASED ON THEIR VALUES
Icon Set Custom
SHOW ICON ONLY (check this box off)
First icon (green checkmark) when value is > = 1 (type: number)
Second icon (no icon) when value is > = -1 (type: number)
Third icon (no icon) when < -1

Now, when I enter a 1 in B4 or any of the B column cells, it will highlight the entire row for me and replace the "1" with a checkmark.

BUILT-IN TEMPLATE WITH THIS FORMATTING:
1) Open Excel, search for a new template. Enter "Inventory" as the search term
2) Select the template titled "Inventory list with highlighting"
3) Highlight the first row of the table, open conditional formats to manage/edit. You will see the 2nd and 3rd formats are for highlights and the icon in the B column. You can change the icon to whatever you want. Remove the first format if you don't want the strikeout options from the Discontinued column.
This comment was minimized by the moderator on the site
I have a question about the initial step of linking the checkbox to a true/false.

1. Select the first check box in I1, enter formula =$J$1 into the formula bar, and then press the Enter key.

2. Repeat step 1 until all check boxes are linked to the adjacent cells.

For the repeat, does it have to be done for each cell or can you get the drag down to autofill? Right now, when I drag down the corner box it will autofill with =$J$1 for everything so that if I check one box, every box is checked. How can I fix this without manually linking each checkbox?
This comment was minimized by the moderator on the site
Hi,
The Fill Handle can't help in this case. You need to manually link each checkbox to its adjacent cell.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
Rate this post:
0   Characters
Suggested Locations