• DİKKAT

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

Satır renklendirme ile ilgili kod kısaltma

NBATMAN

Destek Ekibi
Destek Ekibi
Katılım
1 Aralık 2007
Mesajlar
665
Excel Vers. ve Dili
Office 2003 excel Türkçe
Merhaba,

Aşağıdaki kodları formdan buldum, Bunların daha kısa hallerinin kullanımı için yardımcı olur musunuz?

For i = 1 To 369
If Cells(i, 14).Value < 0 Then Cells(i, 1).Interior.ColorIndex = 15 Else Cells(i, 1).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 2).Interior.ColorIndex = 15 Else Cells(i, 2).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 3).Interior.ColorIndex = 15 Else Cells(i, 3).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 4).Interior.ColorIndex = 15 Else Cells(i, 4).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 5).Interior.ColorIndex = 15 Else Cells(i, 5).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 6).Interior.ColorIndex = 15 Else Cells(i, 6).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 7).Interior.ColorIndex = 15 Else Cells(i, 7).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 8).Interior.ColorIndex = 15 Else Cells(i, 8).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 9).Interior.ColorIndex = 15 Else Cells(i, 9).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 10).Interior.ColorIndex = 15 Else Cells(i, 10).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 11).Interior.ColorIndex = 15 Else Cells(i, 11).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 12).Interior.ColorIndex = 15 Else Cells(i, 12).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 13).Interior.ColorIndex = 15 Else Cells(i, 13).Interior.ColorIndex = xlNone
If Cells(i, 14).Value < 0 Then Cells(i, 14).Interior.ColorIndex = 15 Else Cells(i, 14).Interior.ColorIndex = xlNone
Next
 
Kod:
For i = 1 To 369
    For j = 1 To 14
        If Cells(i, 14).Value < 0 Then
            Cells(i, j).Interior.ColorIndex = 15
        Else
            Cells(i, j).Interior.ColorIndex = xlNone
        End If
    Next
Next
 
eğer hücrelere hiç bir şekilde dolgu rengi verilmediği kesin olarak biliniyor ise aşağıdaki tek satır da yeterlidir.

Kod:
For i = 1 To 369
    For j = 1 To 14
        If Cells(i, 14).Value < 0 Then Cells(i, j).Interior.ColorIndex = 15
    Next
Next
 
İlginiz için çok teşekkür ederim. Saygılarımla,
 
rica ederim.
 
Geri
Üst