• DİKKAT

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

Kod yazma hatası

yanginci34

Altın Üye
Katılım
6 Temmuz 2010
Mesajlar
1,673
Excel Vers. ve Dili
excel2016
Merhaba aşağıdaki kodu çalıştırdığımda Block If without End If hatası oluyor yardımcı olurmusunuz.
Kod:
Private Sub CommandButton1_Click()
a = Sheets("PUANTAJ")
b = Sheets("PUANTAJ 16 00 - 00 00")
c = Sheets("PUANTAJ 00 00 - 08 00")

If ComboBox34 = "08:00 - 17:00" Then
a.Select

        'Combobox1'de yazılan değeri, a sütununda aramaya başla
        Set rngBul = Sheets("PUANTAJ").Columns("a").Find(ComboBox1, Lookat:=xlWhole)
        'Eğer bir tane bile bulursan
        If Not rngBul Is Nothing Then
        
          a.Cells(rngBul.Row, "d") = ComboBox3.Value
          a.Cells(rngBul.Row, "e") = ComboBox4.Value
          a.Cells(rngBul.Row, "f") = ComboBox5.Value
          a.Cells(rngBul.Row, "g") = ComboBox6.Value
          a.Cells(rngBul.Row, "h") = ComboBox7.Value
          a.Cells(rngBul.Row, "ı") = ComboBox8.Value
          a.Cells(rngBul.Row, "j") = ComboBox9.Value
          a.Cells(rngBul.Row, "k") = ComboBox10.Value
          a.Cells(rngBul.Row, "l") = ComboBox11.Value
          a.Cells(rngBul.Row, "m") = ComboBox12.Value
          a.Cells(rngBul.Row, "n") = ComboBox13.Value
          a.Cells(rngBul.Row, "o") = ComboBox14.Value
          a.Cells(rngBul.Row, "p") = ComboBox15.Value
          a.Cells(rngBul.Row, "q") = ComboBox16.Value
          a.Cells(rngBul.Row, "r") = ComboBox17.Value
          a.Cells(rngBul.Row, "s") = ComboBox18.Value
          a.Cells(rngBul.Row, "t") = ComboBox19.Value
          a.Cells(rngBul.Row, "u") = ComboBox20.Value
          a.Cells(rngBul.Row, "v") = ComboBox21.Value
          a.Cells(rngBul.Row, "w") = ComboBox22.Value
          a.Cells(rngBul.Row, "x") = ComboBox23.Value
          a.Cells(rngBul.Row, "y") = ComboBox24.Value
          a.Cells(rngBul.Row, "z") = ComboBox25.Value
          a.Cells(rngBul.Row, "aa") = ComboBox26.Value
          a.Cells(rngBul.Row, "ab") = ComboBox27.Value
          a.Cells(rngBul.Row, "ac") = ComboBox28.Value
          a.Cells(rngBul.Row, "ad") = ComboBox29.Value
          a.Cells(rngBul.Row, "ae") = ComboBox30.Value
          a.Cells(rngBul.Row, "af") = ComboBox31.Value
          a.Cells(rngBul.Row, "ag") = ComboBox32.Value
          a.Cells(rngBul.Row, "ah") = ComboBox33.Value
          a.Cells(rngBul.Row, "aı") = ComboBox36.Value
          a.Cells(rngBul.Row, "aj") = ComboBox37.Value
          a.Cells(rngBul.Row, "ak") = ComboBox38.Value
          a.Cells(rngBul.Row, "al") = ComboBox39.Value
          a.Cells(rngBul.Row, "am") = ComboBox40.Value
          a.Cells(rngBul.Row, "an") = ComboBox41.Value
          a.Cells(rngBul.Row, "ao") = ComboBox42.Value
          a.Cells(rngBul.Row, "ap") = ComboBox43.Value
          a.Cells(rngBul.Row, "aq") = ComboBox44.Value
          a.Cells(rngBul.Row, "ar") = ComboBox45.Value
          a.Cells(rngBul.Row, "as") = ComboBox46.Value
          a.Cells(rngBul.Row, "at") = ComboBox47.Value
          a.Cells(rngBul.Row, "au") = ComboBox48.Value
          a.Cells(rngBul.Row, "av") = ComboBox49.Value
         
   
 ElseIf ComboBox34 = "16:00 - 00:00" Then
b.Select

        'Combobox1'de yazılan değeri, a sütununda aramaya başla
        Set rngBul = Sheets("PUANTAJ 16 00 - 00 00").Columns("a").Find(ComboBox1, Lookat:=xlWhole)
        'Eğer bir tane bile bulursan
        If Not rngBul Is Nothing Then
        
          b.Cells(rngBul.Row, "d") = ComboBox3.Value
          b.Cells(rngBul.Row, "e") = ComboBox4.Value
          b.Cells(rngBul.Row, "f") = ComboBox5.Value
          b.Cells(rngBul.Row, "g") = ComboBox6.Value
          b.Cells(rngBul.Row, "h") = ComboBox7.Value
          b.Cells(rngBul.Row, "ı") = ComboBox8.Value
          b.Cells(rngBul.Row, "j") = ComboBox9.Value
          b.Cells(rngBul.Row, "k") = ComboBox10.Value
          b.Cells(rngBul.Row, "l") = ComboBox11.Value
          b.Cells(rngBul.Row, "m") = ComboBox12.Value
          b.Cells(rngBul.Row, "n") = ComboBox13.Value
          b.Cells(rngBul.Row, "o") = ComboBox14.Value
          b.Cells(rngBul.Row, "p") = ComboBox15.Value
          b.Cells(rngBul.Row, "q") = ComboBox16.Value
          b.Cells(rngBul.Row, "r") = ComboBox17.Value
          b.Cells(rngBul.Row, "s") = ComboBox18.Value
          b.Cells(rngBul.Row, "t") = ComboBox19.Value
          b.Cells(rngBul.Row, "u") = ComboBox20.Value
          b.Cells(rngBul.Row, "v") = ComboBox21.Value
          b.Cells(rngBul.Row, "w") = ComboBox22.Value
          b.Cells(rngBul.Row, "x") = ComboBox23.Value
          b.Cells(rngBul.Row, "y") = ComboBox24.Value
          b.Cells(rngBul.Row, "z") = ComboBox25.Value
          b.Cells(rngBul.Row, "aa") = ComboBox26.Value
          b.Cells(rngBul.Row, "ab") = ComboBox27.Value
          b.Cells(rngBul.Row, "ac") = ComboBox28.Value
          b.Cells(rngBul.Row, "ad") = ComboBox29.Value
          b.Cells(rngBul.Row, "ae") = ComboBox30.Value
          b.Cells(rngBul.Row, "af") = ComboBox31.Value
          b.Cells(rngBul.Row, "ag") = ComboBox32.Value
          b.Cells(rngBul.Row, "ah") = ComboBox33.Value
          b.Cells(rngBul.Row, "aı") = ComboBox36.Value
          b.Cells(rngBul.Row, "aj") = ComboBox37.Value
          b.Cells(rngBul.Row, "ak") = ComboBox38.Value
          b.Cells(rngBul.Row, "al") = ComboBox39.Value
          b.Cells(rngBul.Row, "am") = ComboBox40.Value
          b.Cells(rngBul.Row, "an") = ComboBox41.Value
          b.Cells(rngBul.Row, "ao") = ComboBox42.Value
          b.Cells(rngBul.Row, "ap") = ComboBox43.Value
          b.Cells(rngBul.Row, "aq") = ComboBox44.Value
          b.Cells(rngBul.Row, "ar") = ComboBox45.Value
          b.Cells(rngBul.Row, "as") = ComboBox46.Value
          b.Cells(rngBul.Row, "at") = ComboBox47.Value
          b.Cells(rngBul.Row, "au") = ComboBox48.Value
          b.Cells(rngBul.Row, "av") = ComboBox49.Value
          
          Set rngBul = Nothing
   
ElseIf ComboBox34 = "00:00 - 08:00" Then
c.Select

        'Combobox1'de yazılan değeri, a sütununda aramaya başla
        Set rngBul = Sheets("PUANTAJ 00 00 - 08 00").Columns("a").Find(ComboBox1, Lookat:=xlWhole)
        'Eğer bir tane bile bulursan
        If Not rngBul Is Nothing Then
        
          c.Cells(rngBul.Row, "d") = ComboBox3.Value
          c.Cells(rngBul.Row, "e") = ComboBox4.Value
          c.Cells(rngBul.Row, "f") = ComboBox5.Value
          c.Cells(rngBul.Row, "g") = ComboBox6.Value
          c.Cells(rngBul.Row, "h") = ComboBox7.Value
          c.Cells(rngBul.Row, "ı") = ComboBox8.Value
          c.Cells(rngBul.Row, "j") = ComboBox9.Value
          c.Cells(rngBul.Row, "k") = ComboBox10.Value
          c.Cells(rngBul.Row, "l") = ComboBox11.Value
          c.Cells(rngBul.Row, "m") = ComboBox12.Value
          c.Cells(rngBul.Row, "n") = ComboBox13.Value
          c.Cells(rngBul.Row, "o") = ComboBox14.Value
          c.Cells(rngBul.Row, "p") = ComboBox15.Value
          c.Cells(rngBul.Row, "q") = ComboBox16.Value
          c.Cells(rngBul.Row, "r") = ComboBox17.Value
          c.Cells(rngBul.Row, "s") = ComboBox18.Value
          c.Cells(rngBul.Row, "t") = ComboBox19.Value
          c.Cells(rngBul.Row, "u") = ComboBox20.Value
          c.Cells(rngBul.Row, "v") = ComboBox21.Value
          c.Cells(rngBul.Row, "w") = ComboBox22.Value
          c.Cells(rngBul.Row, "x") = ComboBox23.Value
          c.Cells(rngBul.Row, "y") = ComboBox24.Value
          c.Cells(rngBul.Row, "z") = ComboBox25.Value
          c.Cells(rngBul.Row, "aa") = ComboBox26.Value
          c.Cells(rngBul.Row, "ab") = ComboBox27.Value
          c.Cells(rngBul.Row, "ac") = ComboBox28.Value
          c.Cells(rngBul.Row, "ad") = ComboBox29.Value
          c.Cells(rngBul.Row, "ae") = ComboBox30.Value
          c.Cells(rngBul.Row, "af") = ComboBox31.Value
          c.Cells(rngBul.Row, "ag") = ComboBox32.Value
          c.Cells(rngBul.Row, "ah") = ComboBox33.Value
          c.Cells(rngBul.Row, "aı") = ComboBox36.Value
          c.Cells(rngBul.Row, "aj") = ComboBox37.Value
          c.Cells(rngBul.Row, "ak") = ComboBox38.Value
          c.Cells(rngBul.Row, "al") = ComboBox39.Value
          c.Cells(rngBul.Row, "am") = ComboBox40.Value
          c.Cells(rngBul.Row, "an") = ComboBox41.Value
          c.Cells(rngBul.Row, "ao") = ComboBox42.Value
          c.Cells(rngBul.Row, "ap") = ComboBox43.Value
          c.Cells(rngBul.Row, "aq") = ComboBox44.Value
          c.Cells(rngBul.Row, "ar") = ComboBox45.Value
          c.Cells(rngBul.Row, "as") = ComboBox46.Value
          c.Cells(rngBul.Row, "at") = ComboBox47.Value
          c.Cells(rngBul.Row, "au") = ComboBox48.Value
          c.Cells(rngBul.Row, "av") = ComboBox49.Value
          Set rngBul = Nothing
    End If
    End If
End Sub
 
Sondaki End If'lerden birini silin. Sanırım sorun kalkar.
 
ElseIf ComboBox34 = "16:00 - 00:00" Then den önce end if ekleyin. If Not rngBul Is Nothing Then kısmını kapatmamışsınız.
a.Cells(rngBul.Row, "d") = ComboBox3.Value kısmını döngü ile kodları kısaltabilirsiniz. Örnek dosya olursa daha kısa çözüm sunabiliriz.
 
Rica ederim. Hayırlı akşamlar.
 
Geri
Üst