• DİKKAT

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

Şarta Bağlı 2 Ayrı If Komutunu Kullanabilmek

Katılım
5 Ocak 2009
Mesajlar
1,586
Excel Vers. ve Dili
2003 Türkçe
Selam,
Aşağıdaki kodlar hatalıdır. kırmızı alanlarda 2 ayrı IF bulunmaktadır. Kodlardan da anşılacağı gibi,
Sayfa ismine göre altındaki If komutunun geçerli olmasını istiyorum. döngüler ve kodları ayrı ayrı yazınca sorun olmuyor. Ancak,
Aynı kodları tekrar etmeden bunu nasıl sağlayabilirim?
İyi çalışmalar.

Kod:
If ActiveSheet.Name = "Çeşitler-1" Then
[COLOR="Red"]If c1.Cells(c_sat, "A") = veri.Cells(i, "J") And c1.Cells(c_sat, "B") = veri.Cells(i, "K") And c1.Cells(c_sat, "C") = veri.Cells(i, "L") Then[/COLOR]
End If

If ActiveSheet.Name = "Çeşitler-2" Then
[COLOR="red"]If c2.Cells(c_sat, "A") = veri.Cells(i, "J") And c2.Cells(c_sat, "B") = yaprak And c2.Cells(c_sat, "C") <= veri.Cells(i, "L") And c2.Cells(c_sat, "D") >= veri.Cells(i, "L") Then[/COLOR]
End If

x = x + 1
lv.ListItems.Add
lv.ListItems(x) = veri.Cells(i, "A")
lv.ListItems(x).SubItems(1) = veri.Cells(i, "J")
lv.ListItems(x).SubItems(2) = veri.Cells(i, "K")
lv.ListItems(x).SubItems(3) = veri.Cells(i, "L")
End If
 
Merhaba Ergün bey,
Kod:
If ActiveSheet.Name = "Çeşitler-1" Then
If c1.Cells(c_sat, "A") = veri.Cells(i, "J") And c1.Cells(c_sat, "B") = veri.Cells(i, "K") And c1.Cells(c_sat, "C") = veri.Cells(i, "L") Then
endif
End If

If ActiveSheet.Name = "Çeşitler-2" Then
If c2.Cells(c_sat, "A") = veri.Cells(i, "J") And c2.Cells(c_sat, "B") = yaprak And c2.Cells(c_sat, "C") <= veri.Cells(i, "L") And c2.Cells(c_sat, "D") >= veri.Cells(i, "L") Then
endif
End If
şeklinde denermisiniz, iyi akşamlar.
 
Merhaba Ergün bey,
Kod:
If ActiveSheet.Name = "Çeşitler-1" Then
If c1.Cells(c_sat, "A") = veri.Cells(i, "J") And c1.Cells(c_sat, "B") = veri.Cells(i, "K") And c1.Cells(c_sat, "C") = veri.Cells(i, "L") Then
endif
End If

If ActiveSheet.Name = "Çeşitler-2" Then
If c2.Cells(c_sat, "A") = veri.Cells(i, "J") And c2.Cells(c_sat, "B") = yaprak And c2.Cells(c_sat, "C") <= veri.Cells(i, "L") And c2.Cells(c_sat, "D") >= veri.Cells(i, "L") Then
endif
End If
şeklinde denermisiniz, iyi akşamlar.

Sayın Dentex,
tekrar hoşgeldiniz. Denedim olmadı.
İyi çalışmalar.
 
Merhaba,
hoşbulduk :). Dosya ekleyebilirseniz daha sağlıklı test edebiliriz, saygılar.
 
Merhaba.
sayfa ismini içeren satırlar için Select Case'li bir yapı olabilir mi?
 
örnek:

Kod:
Sub WoksheetsByName()

Dim ws As Worksheet
'http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm

    For Each ws In Worksheets
        'Select case is case sensitive
        'http://www.ozgrid.com/VBA/select-case.htm
        Select Case UCase(ws.Name)
           Case "SHEET1", "SHEET3", "SHEET5" 'ect
                With ws
            
                    'With Code Here
            
                End With
           'Optional use when most sheets are to be used
           'In this case, use "Case" to name sheets to be NOT used
           Case Else
                With ws
        
                    'With Code Here
        
                End With
     End Select
     
    Next ws

End Sub

veya
Kod:
Sub WoksheetsByNamingConvention()

Dim ws As Worksheet
'http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm
    For Each ws In Worksheets
    
       If ws.Name Like "Data*" Then
                With ws
            
                    'With Code Here
            
                End With
       End If
     
    Next ws

End Sub
 
Geri
Üst