• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Koşullu biçimlendirme kodunu kısaltmak

Katılım
15 Temmuz 2012
Mesajlar
2,802
Excel Vers. ve Dili
Ofis 2021 TR 64 Bit
Merhaba arkadaşlar makro kaydet ile oluşturduğum aşağıdaki kodda gereksiz yerleri kırpmak ve kodu hafifletmek istiyorum.

Yardım edeceklere teşekkür ediyorum.

Kod:
Sub renk_ve_kenarlık()
    Range("A1:L500").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A1<>"""""
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Borders(xlLeft)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.FormatConditions(1).Borders(xlRight)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.FormatConditions(1).Borders(xlTop)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.FormatConditions(1).Borders(xlBottom)
        .LineStyle = xlContinuous
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 49407
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = True
End Sub
 

Ekli dosyalar

Son düzenleme:
Merhaba.
Sanırım aşağıdaki şekilde oluyor.
Eğer aynı alan için, ilave koşullu biçimlendirme yoksa sondaki kırmızı satır gereksiz, silebilirsiniz.
Kod:
Sub renk_ve_kenarlık()
Range("A1:L500").FormatConditions.Add Type:=xlExpression, Formula1:="=$A1<>"""""
Range("A1:L500").FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Range("A1:L500").FormatConditions(1)
        .Borders.LineStyle = xlContinuous
        .Interior.Color = 49407
    End With
[B][COLOR="Red"]Selection.FormatConditions(1).StopIfTrue = True[/COLOR][/B]
End Sub
 
Son düzenleme:
Ömer Bey ilginize ve emeğinize çok teşekkür ediyorum gerçekten çok işime yaradı, Allah razı olsun.
Maalesef makroda fazla ilerleyemiyorum, sorduğum çok soruya cevap verdiniz hakkınızı helal edin.

Hayırlı akşamlar.
 
Estağfurullah.
Benim de kod bilgimin iyi olduğu söylenemez.
İyi günler dilerim.
 
Geri
Üst