Ana içeriğe atla

Excel'de renk doldururken ızgara çizgileri nasıl korunur?

Hepimizin bildiği gibi, hücrelere arka plan rengini doldurduğumuzda, kılavuz çizgileri de ele alınacaktır, bu durumda, gösterilen aşağıdaki ekran görüntüsünü elde etmek için Excel hücrelerinde arka plan rengini doldururken kılavuz çizgilerini nasıl koruyabiliriz.

doc kılavuz çizgilerini dolgu rengi 1'i koru

Renkleri VBA koduyla doldururken kılavuz çizgilerini koruyun


ok mavi sağ balon Renkleri VBA koduyla doldururken kılavuz çizgilerini koruyun

Normalde bu işi çözmemizin doğrudan bir yolu yoktur, ancak burada sizin için bir VBA kodu sunabilirim. Lütfen aşağıdaki işlemleri yapın:

1. Basılı tutun ALT + F11 tuşlarını açmak için Uygulamalar için Microsoft Visual Basic pencere.

2. Solda Proje-VBAProject bölme, çift tıklama Bu Çalışma Kitabı genişletilmiş altında VBAProjesi, ardından aşağıdaki VBA kodunu boş Modüle kopyalayıp yapıştırın:

VBA kodu: rengi doldururken kılavuz çizgilerini koruyun

Dim xRgPre As Range
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    On Error Resume Next
    If Not xRgPre Is Nothing Then DrawBorders xRgPre
    Set xRgPre = Target
End Sub
Private Sub DrawBorders(ByVal Rg As Range)
'Updateby Extendoffice 20160725
    Dim xCell As Range
    Application.ScreenUpdating = False
    For Each xCell In Rg
        If xCell.Interior.ColorIndex = xlNone Then
            With xCell.Borders
                If .ColorIndex = 15 Then
                    .LineStyle = xlNone
                End If
            End With
        Else
            With xCell.Borders
                If .LineStyle = xlNone Then
                    .Weight = xlThin
                    .ColorIndex = 15
                End If
            End With
        End If
    Next
    Application.ScreenUpdating = True
End Sub

doc kılavuz çizgilerini dolgu rengi 2'i koru

3. Ve sonra kod penceresini kaydedip kapatın, şimdi, bir dizi hücre için bir renk doldurduğunuzda, kılavuz çizgileri otomatik olarak gösterilecektir.

En İyi Ofis Üretkenlik Araçları

🤖 Kutools AI Yardımcısı: Aşağıdakilere dayalı olarak veri analizinde devrim yaratın: Akıllı Yürütme   |  Kodunu oluşturun  |  Özel Formüller Oluşturun  |  Verileri Analiz Edin ve Grafikler Oluşturun  |  Kutools İşlevlerini Çağır...
Popüler Özellikler: Yinelenenleri Bul, Vurgula veya Tanımla   |  Boş Satırları Sil   |  Veri Kaybı Olmadan Sütunları veya Hücreleri Birleştirin   |   Formülsüz Tur ...
Süper Arama: Çoklu Ölçütlü VLookup    Çoklu Değer VLookup  |   Birden Çok Sayfada VLookup   |   Bulanık Arama ....
Gelişmiş Açılır Liste: Hızla Açılır Liste Oluşturun   |  Bağımlı Açılır Liste   |  Çoklu Seçim Açılır Liste ....
Sütun Yöneticisi: Belirli Sayıda Sütun Ekleme  |  Sütunları Taşı  |  Gizli Sütunların Görünürlük Durumunu Değiştir  |  Aralıkları ve Sütunları Karşılaştırın ...
Öne Çıkan Özellikler: Izgara Odağı   |  Tasarım görünümü   |   Büyük Formül Çubuğu    Çalışma Kitabı ve Sayfa Yöneticisi   |  Kaynak Kütüphanesi (Otomatik metin)   |  Tarih Seçici   |  Çalışma Sayfalarını Birleştirin   |  Hücreleri Şifrele/Şifresini Çöz    E-postaları Listeye Göre Gönder   |  Süper Filtre   |   Özel Filtre (kalın/italik/üstü çizili filtre...) ...
En İyi 15 Araç Seti12 Metin Tools (Metin ekle, Karakterleri Kaldır, ...)   |   50+ Grafik Türleri (Gantt şeması, ...)   |   40+ Pratik Formüller (Yaşı doğum gününe göre hesapla, ...)   |   19 sokma Tools (QR Kodunu Girin, Yoldan Resim Ekle, ...)   |   12 Dönüştürme Tools (Sayılardan Kelimelere, Para Birimi Dönüştürme, ...)   |   7 Birleştir ve Böl Tools (Gelişmiş Kombine Satırları, Bölünmüş hücreler, ...)   |   ... ve dahası

Kutools for Excel ile Excel Becerilerinizi Güçlendirin ve Daha Önce Hiç Olmadığı Gibi Verimliliği Deneyimleyin. Kutools for Excel, Üretkenliği Artırmak ve Zamandan Tasarruf Etmek için 300'den Fazla Gelişmiş Özellik Sunar.  En Çok İhtiyacınız Olan Özelliği Almak İçin Buraya Tıklayın...

Açıklama


Office Tab, Office'e Sekmeli Arayüz Getirir ve İşinizi Çok Daha Kolay Hale Getirir

  • Word, Excel, PowerPoint'te sekmeli düzenlemeyi ve okumayı etkinleştirin, Publisher, Access, Visio ve Project.
  • Yeni pencereler yerine aynı pencerenin yeni sekmelerinde birden çok belge açın ve oluşturun.
  • Üretkenliğinizi% 50 artırır ve her gün sizin için yüzlerce fare tıklamasını azaltır!
Comments (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Is this universally and automatically applied to new tables or sheets opened? Or need to do this for each table or sheet you want to have it? How to make it universally and automatically applied to new tables or sheets?
This comment was minimized by the moderator on the site
Simply change MS Office to Open Office...
This comment was minimized by the moderator on the site
Danke für den super Tipp!
This comment was minimized by the moderator on the site
This works great. (Thanks) But here's the real question - Why does Excel allow gridlines to disappear when filling cells with color in the first place? Just another dumb glitch in the techy world that so-called intelligent developers never think of. I mean, the gridlines, by default are supposed to be there anyway...so....
This comment was minimized by the moderator on the site
Thank you! I was pulling hairs trying to get the nice grey-ish borders to stay after colorizing. Can't believe Microsoft hasn't already implemented this.
This comment was minimized by the moderator on the site
Another fix, if you don't want to mess with code:
First figure out which color gray matches the default lines and have it in mind.
In the Home tab click Cell styles, right click on Normal, click Modify -> Format -> Border. For Line Color, select that gray. For Presets, select Outline. Done.
Now you may have to select all (CTRL+A / Command+A) and click Cell styles -> Normal to make sure it's applied to all cells. When you fill a cell, the borders will remain.
This comment was minimized by the moderator on the site
Very helpful- thank you
This comment was minimized by the moderator on the site
This helped me SO much. I have literally been searching so many places and this is the only explanation that worked! Thank you!!!
This comment was minimized by the moderator on the site
Alissa , I had the same problem couldn`t get it fixed but your reply helped me a lot , so thank you very much , you are genius .
This comment was minimized by the moderator on the site
Thank you!!
This comment was minimized by the moderator on the site
Cool, but now if I fill some cells, and hit Ctrl+Z to undo, it won't work. Will not undo.
This comment was minimized by the moderator on the site
Hello, Andrew,
Yes, the above code can not support Undo feature, you should fill no color manually to undo your work.
Thank you!
This comment was minimized by the moderator on the site
use only standard colors ;)
This comment was minimized by the moderator on the site
works but one has to correct the error if you see it.
Dim xRgPre As Range
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
If Not xRgPre Is Nothing Then DrawBorders xRgPre
Set xRgPre = Target


*************************************
Should READ... as the If statement only ensures that something is there to set to memory allocation.

One could set the next line below for clean up and not allow memory leaks.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next
Set xRgPre = Target
If Not xRgPre Is Nothing Then DrawBorders xRgPre
'For ensured memory leaks do not happen
'Clean up the memory allocated after it is not needed.
Set xRqPre = Nothing



Have a nice day..
This comment was minimized by the moderator on the site
Does not work with Conditional Formatting. Set xRqPre = Nothing gives error: variable not defined (deleted the line).Screen jiggles here too, using 2010. Other wise its a cool tool..
This comment was minimized by the moderator on the site
Works fine, but sadly every time I now click on a cell, the worksheet judders! Removed the VBA and the judder has ceased. Wonder why this should happen?
This comment was minimized by the moderator on the site
Same here with Excel 2016. I'm getting freezing and mostly blanked out screen for several seconds, especially when selecting many cells. It's a shame because it does work perfectly otherwise.
This comment was minimized by the moderator on the site
Hi, Vic,
There is no this problem in my Excel workbook, which Excel version do you use?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations