• DİKKAT

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

vba döngü ile büyüktür küçüktür işlemi

Katılım
17 Kasım 2009
Mesajlar
295
Excel Vers. ve Dili
2010
merhaba arkadaşlar aşağıdaki kodu öğrenci notu 49 dan küçükse notun yanına boşluk bırakıp "-" işareti eklesin 49 dan büyükse + eklemesini istiyorum.

For i = 5 To 18

If Worksheets("sayfa4").Cells(i, 16) > 49 Then
Cells(i, 16).Interior.ColorIndex = 2

Else
Cells(i, 16).Interior.ColorIndex = 3
End If
Next i
 
Merhaba.

Kod:
Sub Test()
    For i = 5 To 18
        If Worksheets("sayfa1").Cells(i, "P") > 49 Then
            Cells(i, "P").Interior.ColorIndex = 2
            Cells(i, "P") = "'+ " & Cells(i, "P")
        Else
            Cells(i, "P").Interior.ColorIndex = 3
            Cells(i, "P") = "'- " & Cells(i, "P")
        End If
        Cells(i, "P").NumberFormat = "@"
    Next i
End Sub
 
Değeri değiştirmeden hücre biçimi olarak kullanmak isterseniz aşağıdaki gibi deneyin:

PHP:
For i = 5 To 18
    If Worksheets("sayfa4").Cells(i, 16) > 49 Then
        Cells(i, 16).Interior.ColorIndex = 2
        Cells(i, 16).NumberFormat = "0"" +"""
    Else
        Cells(i, 16).Interior.ColorIndex = 3
        Cells(i, 16).NumberFormat = "0"" -"""
    End If
Next i
 
49 ise ne olacak! :D
 
Geri
Üst