• DİKKAT

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

Select Case Döngüsünde Sonuç Yanlış Çıkıyor.

ahmed_ummu

Altın Üye
Katılım
28 Mart 2011
Mesajlar
777
Excel Vers. ve Dili
Excel 2010 Professional Plus 64 Bit
Merhaba arkadaşlar.

Aşağıdaki kod ile almak istediğim sonuç yanlış çıkıyor. Ekteki resimde anlatmaya çalıştım. Dosyam büyük olduğu için eklemedim. Yardımcı olursanız çok sevinirim.

Set s1 = Sheets("ÜP_1-31")
Set S2 = Sheets("ÜBB")

s = 12
For i = 8 To s1.Cells(Rows.Count, 2).End(xlUp).Row
S2.Cells(s, 2).Value = s1.Cells(i, 2).Value
S2.Cells(s, 3).Value = s1.Cells(i, 38).Value

Select Case s1.Cells(i, 3).Value
Case Is = "GÜNDÜZ"
S2.Cells(s, 4).Value = s1.Cells(i, 35).Value
S2.Cells(s, 5).Value = s1.Cells(i, 36).Value
S2.Cells(s, 6).Value = s1.Cells(i, 37).Value

Case Is = "GECE"
S2.Cells(s, 8).Value = s1.Cells(i, 35).Value
S2.Cells(s, 9).Value = s1.Cells(i, 36).Value
S2.Cells(s, 10).Value = s1.Cells(i, 37).Value

Case Is = "DYK GÜNDÜZ"
S2.Cells(s, 12).Value = s1.Cells(i, 35).Value
S2.Cells(s, 13).Value = s1.Cells(i, 36).Value
S2.Cells(s, 14).Value = s1.Cells(i, 37).Value

Case Is = "DYK H.S."
S2.Cells(s, 16).Value = s1.Cells(i, 35).Value
S2.Cells(s, 17).Value = s1.Cells(i, 36).Value
S2.Cells(s, 18).Value = s1.Cells(i, 37).Value
End Select

s = s + 1
Next i
 

Ekli dosyalar

  • örnek10.jpg
    örnek10.jpg
    451.2 KB · Görüntüleme: 7
Merhaba, sadece s1 ve s2 olarak belirttiğiniz sayfalar olacak şekilde örnek dosya paylaşabilirsiniz. Bu şekilde dosya boyutu da az olacaktır.
 
For i = 8 To s1.Cells(Rows.Count, 2).End(xlUp).Row satırından sonra aşağıdaki kodu ekleyiniz.
Kod:
If s2.Cells(s - 1, 2) <> "" Then
    son = s2.Range("B" & Rows.Count).End(3).Row
    Set bul = s2.Range("B12:B" & son + 1).Find(s1.Cells(i, 2), lookat:=xlWhole)
    If Not bul Is Nothing Then s = bul.Row
End If
 
For i = 8 To s1.Cells(Rows.Count, 2).End(xlUp).Row satırından sonra aşağıdaki kodu ekleyiniz.
Kod:
If s2.Cells(s - 1, 2) <> "" Then
    son = s2.Range("B" & Rows.Count).End(3).Row
    Set bul = s2.Range("B12:B" & son + 1).Find(s1.Cells(i, 2), lookat:=xlWhole)
    If Not bul Is Nothing Then s = bul.Row
End If

Sayın AdemCan çok teşekkür ederim. İstediğim sonuç çıkıyor.
 
Rica ederim.
 
Geri
Üst