Combobox'ta veri seçmeye zorlama

serif_007

Altın Üye
Katılım
5 Nisan 2014
Mesajlar
155
Excel Vers. ve Dili
Excel 2019
Altın Üyelik Bitiş Tarihi
16-07-2027
Merhabalar bir Userform üzerinde textboxlar ve comboboxlar ile veri girişi yapıyorum. Örneğin Combobox 1, Combobox 2 ,Combobox 3 ,Combobox 4 ,Combobox 5
verilerin boş geçilmesini istemiyorum. Veriler Commandbutton1 ile kayıt ediliyor.
Kod:
If ComboBox5.Value = "" Then
    MsgBox "Combobox5'i boş geçtiniz!", vbCritical, "UYARI"
    Cancel = True
    Exit Sub
End If
bu kod ile uyarı veriyorum fakat yine de kayıt yapıyor. Nasıl bir düzenleme yapmalıyım ki combobox1 boş bırakıldığında hem uyarı versin hemde kayıt yapmasın.
 

hamitcan

Uzman
Uzman
Katılım
1 Temmuz 2004
Mesajlar
7,701
Excel Vers. ve Dili
Excel 2019 Türkçe
Böyle deneyin.
Kod:
Private Sub CommandButton1_Click()
    If ComboBox1 = "" Then  MsgBox "boş": exit sub Else MsgBox "dolu"       
End Sub
 

Necdet

Moderatör
Yönetici
Katılım
4 Haziran 2005
Mesajlar
15,359
Excel Vers. ve Dili
Ofis 365 Türkçe
Merhaba,
Comboboxın Style ni ayarlarsanız kişi kafasına göre bir şey yazamaz.
Bunu iki şekilde yapabilirsiniz.
Ya Comboboxın özelliklerinden Style bulup bunu 2 yapacaksınız, ya da formun initialize kısmanda aşağıdaki kodu kullanarak.

Kod:
ComboBox1.Style = fmStyleDropDownList
 

serif_007

Altın Üye
Katılım
5 Nisan 2014
Mesajlar
155
Excel Vers. ve Dili
Excel 2019
Altın Üyelik Bitiş Tarihi
16-07-2027
Merhaba,
Comboboxın Style ni ayarlarsanız kişi kafasına göre bir şey yazamaz.
Bunu iki şekilde yapabilirsiniz.
Ya Comboboxın özelliklerinden Style bulup bunu 2 yapacaksınız, ya da formun initialize kısmanda aşağıdaki kodu kullanarak.

Kod:
ComboBox1.Style = fmStyleDropDownList
Necdet bey. Çok teşekkür ederim fakat sanırım ben durumu yanlış anlattım. Yapmak istediğim şey şu. 5 tane combobox var diyelim 4 combobox birbiri ile bağlantılı çalışıyor. Örneğin Combobox1'de Aydın seçildi Combobox2'de Aydın'ın ilçeleri listeleniyor. Combobox3 ve 4'te aynı mantıkla çalışıyor. Bu Comboboxlardan herhangi bir tanesi boş geçildiğinde program mesela Combobox5'i boş geçtiniz şeklinde uyarı versin ve kaydı listeye eklemesin. Kodları eklesem sanırım daha kolay olacak :)
Kod:
Dim SonSatır, aranan, degistir_satir, sil_satır As Variant
Private Sub CommandButton16_Click()
On Error GoTo Bitir:
CommandButton1.Enabled = True
TextBox_ID.Value = ""
'TextBox1.Value = ""
ComboBox1.Clear
ComboBox2.Clear
TextBox4.Value = ""
ComboBox3.Clear
ComboBox4.Clear
TextBox15.Value = ""
TextBox8.Value = ""
TextBox16.Value = ""
TextBox10.Value = ""
TextBox11.Value = ""
ComboBox5.Clear
TextBox13.Value = ""
TextBox14.Value = ""

son = Sheets("Veriler").Cells(Rows.Count, 1).End(3).Row
veri = Sheets("Veriler").Range("A2:A" & son)

Set liste = CreateObject("Scripting.Dictionary")

For x = 1 To UBound(veri)
If Not liste.Exists(veri(x, 1)) Then liste.Add veri(x, 1), veri(x, 1)
Next

If liste.Count > 0 Then
ComboBox1.List = liste.Keys
Bitir:
End If



End Sub

Private Sub CommandButton8_Click()
  Dim BLG As String, SY As Long, KRK
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

Set evn = CreateObject("scripting.filesystemobject")
    sekme_ismi = "GÜNCEL ARIZALAR"
KRK = Array("<", ">", "|", "/", " / ", "*", ":", "\", " \ ", ".", "?", """")
For SY = LBound(KRK) To UBound(KRK)
Next SY
    DosyaAdi = "C:\Users\" & Environ("Username") & "\Desktop\" & "GÜNCEL ARIZALAR" & " " & " - " & Date & "  " & ".xlsx"
 
    Sheets(sekme_ismi).Copy
    ActiveWorkbook.SaveAs Filename:=DosyaAdi, FileFormat:= _
        xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
    Application.Visible = False
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
End Sub
Private Sub CommandButton9_Click()
  Dim BLG As String, SY As Long, KRK
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

Set evn = CreateObject("scripting.filesystemobject")
    sekme_ismi = "SONUÇLANAN ARIZALAR"
KRK = Array("<", ">", "|", "/", " / ", "*", ":", "\", " \ ", ".", "?", """")
For SY = LBound(KRK) To UBound(KRK)
Next SY
    DosyaAdi = "C:\Users\" & Environ("Username") & "\Desktop\" & "SONUÇLANAN ARIZALAR" & " " & " - " & Date & "  " & ".xlsx"
 
    Sheets(sekme_ismi).Copy
    ActiveWorkbook.SaveAs Filename:=DosyaAdi, FileFormat:= _
        xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
    Application.Visible = False
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
End Sub

Private Sub Label17_Click()

End Sub

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox_ID = ListBox1.List(ListBox1.ListIndex, 0) 'ListBox'a tıkladığımızda değerleri textbox'lara alıyoruz.
TextBox1 = Format(ListBox1.List(ListBox1.ListIndex, 1), "dd.mm.yyyy hh:mm")
ComboBox1 = ListBox1.List(ListBox1.ListIndex, 2)
ComboBox2 = ListBox1.List(ListBox1.ListIndex, 3)
TextBox4 = ListBox1.List(ListBox1.ListIndex, 4)
ComboBox3 = ListBox1.List(ListBox1.ListIndex, 5)
ComboBox4 = ListBox1.List(ListBox1.ListIndex, 6)
TextBox15 = ListBox1.List(ListBox1.ListIndex, 7)
TextBox8 = ListBox1.List(ListBox1.ListIndex, 8)
TextBox16 = ListBox1.List(ListBox1.ListIndex, 9)
TextBox10 = ListBox1.List(ListBox1.ListIndex, 10)
TextBox11 = ListBox1.List(ListBox1.ListIndex, 11)
ComboBox5 = ListBox1.List(ListBox1.ListIndex, 12)
TextBox13 = ListBox1.List(ListBox1.ListIndex, 13)
TextBox14 = ListBox1.List(ListBox1.ListIndex, 14)
CommandButton1.Enabled = False
CommandButton4.Enabled = True



End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If MsgBox("Kapatilsin mi ?", vbYesNo) = vbNo Then
    Cancel = True
Else
    Application.DisplayAlerts = False
    ActiveWorkbook.Save
    Application.DisplayAlerts = True
    Excel.Application.Quit
End If
End Sub

Private Sub ComboBox4_Change()
If TextBox16.Text <> "" Then
Else
TextBox16.Text = Application.StatusBar
End If
End Sub




Private Sub CommandButton1_Click()
SonSatır = WorksheetFunction.CountA(Worksheets("GÜNCEL ARIZALAR").Range("A:A")) + 1
If SonSatır = 2 Then
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 1) = 1
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 2) = TextBox1.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 3) = ComboBox1.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 4) = ComboBox2.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 5) = TextBox4.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 6) = ComboBox3.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 7) = ComboBox4.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 8) = TextBox15.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 9) = TextBox8.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 10) = TextBox16.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 11) = TextBox10.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 12) = TextBox11.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 13) = ComboBox5.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 14) = TextBox13.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 15) = TextBox14.Value
Else
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 1) = Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır - 1, 1) + 1
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 2) = TextBox1.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 3) = ComboBox1.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 4) = ComboBox2.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 5) = TextBox4.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 6) = ComboBox3.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 7) = ComboBox4.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 8) = TextBox15.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 9) = TextBox8.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 10) = TextBox16.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 11) = TextBox10.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 12) = TextBox11.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 13) = ComboBox5.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 14) = TextBox13.Value
Worksheets("GÜNCEL ARIZALAR").Cells(SonSatır, 15) = TextBox14.Value
End If


Application.ScreenUpdating = True
ActiveWorkbook.Save
'TextBox1.Value = ""
ComboBox1.Clear
ComboBox2.Clear
TextBox4.Value = ""
ComboBox3.Clear
ComboBox4.Clear
TextBox15.Value = ""
TextBox8.Value = ""
TextBox16.Value = ""
TextBox10.Value = ""
TextBox11.Value = ""
ComboBox5.Clear
TextBox13.Value = ""
TextBox14.Value = ""
son = Sheets("Veriler").Cells(Rows.Count, 1).End(3).Row
veri = Sheets("Veriler").Range("A2:A" & son)
Set liste = CreateObject("Scripting.Dictionary")
For x = 1 To UBound(veri)
If Not liste.Exists(veri(x, 1)) Then liste.Add veri(x, 1), veri(x, 1)
Next
If liste.Count > 0 Then
ComboBox1.List = liste.Keys
End If
Me.Repaint
End Sub

Private Sub CommandButton2_Click()
CommandButton4.Enabled = True
On Error GoTo Bitir
aranan = InputBox("Lütfen arama yapmak için arıza ID giriniz!", "Arama Yap", " ")

Range("A:A").Find(aranan).Select
sil_satır = ActiveCell.Row
        TextBox_ID.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 1)
        TextBox1.Value = Format(Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 2), "dd.mm.yyyy hh:mm")
        ComboBox1.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 3)
        ComboBox2.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 4)
        TextBox4.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 5)
        ComboBox3.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 6)
        ComboBox4.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 7)
        TextBox15.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 8)
        TextBox8.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 9)
        TextBox16.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 10)
        TextBox10.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 11)
        TextBox11.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 12)
        ComboBox5.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 13)
        TextBox13.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 14)
        TextBox14.Value = Worksheets("GÜNCEL ARIZALAR").Cells(sil_satır, 15)

    CommandButton1.Enabled = False
Exit Sub
Bitir: MsgBox "Girilen Arıza ID'ye göre kayıt bulunamadı"
End Sub


Private Sub CommandButton3_Click()
           sifre = InputBox("Şifre Giriniz", "Şifre Giriş")
              
If sifre = 134679 Then
        If TextBox_ID.Value <> "" Then
    Dim Komut As Integer
    Dim Mesaj As String
    Dim Baslik As String
    
    Mesaj = TextBox_ID.Value & " numaralı arıza kaydı silinecek emin misiniz?.."
    Baslik = "Silme İşlemi"
    Komut = MsgBox(Mesaj, vbYesNo + vbQuestion, Baslik)
        If Komut = 6 Then
            Rows(ActiveCell.Row).Delete
            TextBox_ID = ""
            'TextBox1.Value = ""
            ComboBox1.Clear
            ComboBox2.Clear
            TextBox4.Value = ""
            ComboBox3.Clear
            ComboBox4.Clear
            TextBox15.Value = ""
            TextBox8.Value = ""
            TextBox16.Value = ""
            TextBox10.Value = ""
            TextBox11.Value = ""
            ComboBox5.Clear
            TextBox13.Value = ""
            TextBox14.Value = ""
        Else
        MsgBox "Silme işlemi iptal edildi!.."
        End If
        Else
        MsgBox "Öncelikle bul butonu yardımı ile bir kayıt seçmelisiniz!.."
         End If
         Else
        MsgBox "Girilen şifre yanlış!.."
            End If
            son = Sheets("Veriler").Cells(Rows.Count, 1).End(3).Row
veri = Sheets("Veriler").Range("A2:A" & son)
Set liste = CreateObject("Scripting.Dictionary")
For x = 1 To UBound(veri)
If Not liste.Exists(veri(x, 1)) Then liste.Add veri(x, 1), veri(x, 1)
Next
If liste.Count > 0 Then
ComboBox1.List = liste.Keys
End If
End Sub

Private Sub CommandButton4_Click()
On Error GoTo Bitir
aranan = TextBox_ID.Value
Range("A:A").Find(aranan).Select
degistir_satir = ActiveCell.Row
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 2) = TextBox1.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 3) = ComboBox1.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 4) = ComboBox2.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 5) = TextBox4.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 6) = ComboBox3.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 7) = ComboBox4.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 8) = TextBox15.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 9) = TextBox8.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 10) = TextBox16.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 11) = TextBox10.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 12) = TextBox11.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 13) = ComboBox5.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 14) = TextBox13.Value
Worksheets("GÜNCEL ARIZALAR").Cells(degistir_satir, 15) = TextBox14.Value

    Dim xRg As Range
    Dim xCell As Range
    Dim i As Long
    Dim J As Long
    Dim K As Long
    i = Worksheets("GÜNCEL ARIZALAR").UsedRange.Rows.Count
    J = Worksheets("SONUÇLANAN ARIZALAR").UsedRange.Rows.Count
    If J = 1 Then
       If Application.WorksheetFunction.CountA(Worksheets("SONUÇLANAN ARIZALAR").UsedRange) = 0 Then J = 0
    End If
    Set xRg = Worksheets("GÜNCEL ARIZALAR").Range("P1:P" & i)
    On Error Resume Next
    Application.ScreenUpdating = False
    For K = 1 To xRg.Count
        If CStr(xRg(K).Value) = "Arıza Giderildi." Then
            xRg(K).EntireRow.Copy Destination:=Worksheets("SONUÇLANAN ARIZALAR").Range("A" & J + 1)
            xRg(K).EntireRow.Delete
            If CStr(xRg(K).Value) = "Arıza Giderildi." Then
                K = K - 1
            End If
            J = J + 1
        End If
    Next
    Application.ScreenUpdating = True
Bitir:
 TextBox_ID = ""
            'TextBox1.Value = ""
            ComboBox1.Clear
            ComboBox2.Clear
            TextBox4.Value = ""
            ComboBox3.Clear
            ComboBox4.Clear
            TextBox15.Value = ""
            TextBox8.Value = ""
            TextBox16.Value = ""
            TextBox10.Value = ""
            TextBox11.Value = ""
            ComboBox5.Clear
            TextBox13.Value = ""
            TextBox14.Value = ""
CommandButton1.Enabled = True


End Sub
 

serif_007

Altın Üye
Katılım
5 Nisan 2014
Mesajlar
155
Excel Vers. ve Dili
Excel 2019
Altın Üyelik Bitiş Tarihi
16-07-2027
Kod:
Private Sub CommandButton5_Click()
Application.ScreenUpdating = False
    Sheets("GÜNCEL ARIZALAR").Select
    Application.ScreenUpdating = True
    ActiveWindow.SelectedSheets.PrintPreview
End Sub

Private Sub CommandButton6_Click()
Application.Visible = False
'ThisWorkbook.deg = 1
Dim DosyaSistemi
Set DosyaSistemi = CreateObject("Scripting.FileSystemObject")
Dim Yedek_Dosya_Adı As String, Kayıt_Yeri As String
yer = "\\files.admelektrik.com.tr\Aydem\Sistem_Isletme_Md\Scada_Yn\SCADA\SCADA ARIZA KAYIT YEDEK\" & Format(Date, "yyyy-mmmm") & "\"
For i = 1 To Len(ThisWorkbook.Name)
If Mid(ThisWorkbook.Name, i, 1) = "." Then
dosya = Mid(ThisWorkbook.Name, 1, i - 1)
uzanti = Mid(ThisWorkbook.Name, i, Len(ThisWorkbook.Name))
End If
Next
Application.Calculation = xlCalculationAutomatic
ActiveWorkbook.Save
Application.DisplayAlerts = False
Yedek_Dosya_Adı = dosya & Format(Now, " dd_mm_yyyy hh_mm") & uzanti
Kayıt_Yeri = yer & Yedek_Dosya_Adı
On Error Resume Next
If Dir(yer) = "" Then MkDir yer
On Error Resume Next
DosyaSistemi.CopyFile ThisWorkbook.FullName, Kayıt_Yeri
ActiveWorkbook.Password = ""
Application.DisplayAlerts = True
Application.Quit
End Sub


Private Sub ComboBox1_Click()
ComboBox2.Clear
ComboBox3.Clear
ComboBox4.Clear
ComboBox5.Clear
TextBox4.Value = ""
TextBox15.Value = ""



son = Sheets("Veriler").Cells(Rows.Count, 1).End(3).Row
veri1 = Sheets("Veriler").Range("a2:a" & son)
veri2 = Sheets("Veriler").Range("b2:b" & son)
veri3 = Sheets("Veriler").Range("g2:h" & son)
Set liste = CreateObject("Scripting.Dictionary")
Set liste2 = CreateObject("Scripting.Dictionary")
For x = 1 To UBound(veri1)

If veri1(x, 1) = ComboBox1.Text Then
If Not liste.Exists(veri2(x, 1)) Then
liste.Add veri2(x, 1), veri2(x, 1)

End If
If Not liste2.Exists(veri3(x, 1)) Then
liste2.Add veri3(x, 1), veri3(x, 1)

End If
End If
Next

If liste.Count > 0 Then
ComboBox2.List = liste.Keys
End If
If liste.Count > 0 Then
ComboBox5.List = liste2.Keys
End If

End Sub

Private Sub ComboBox2_Click()
ComboBox3.Clear

son = Sheets("Veriler").Cells(Rows.Count, 1).End(3).Row
veri1 = Sheets("Veriler").Range("a2:a" & son)
veri2 = Sheets("Veriler").Range("b2:b" & son)
veri3 = Sheets("Veriler").Range("c2:c" & son)

Set liste = CreateObject("Scripting.Dictionary")

For x = 1 To UBound(veri1)

If veri1(x, 1) & veri2(x, 1) = ComboBox1.Text & ComboBox2.Text Then

If Not liste.Exists(veri3(x, 1)) Then
liste.Add veri3(x, 1), veri3(x, 1)

End If
End If
Next

If liste.Count > 0 Then
ComboBox3.List = liste.Keys
End If

End Sub


Private Sub ComboBox3_Click()
ComboBox4.Clear

son = Sheets("Veriler").Cells(Rows.Count, 1).End(3).Row
veri1 = Sheets("Veriler").Range("c2:a" & son)
veri2 = Sheets("Veriler").Range("d2:b" & son)
veri3 = Sheets("Veriler").Range("e2:c" & son)
veri4 = Sheets("Veriler").Range("f2:d" & son)

Set liste = CreateObject("Scripting.Dictionary")

For x = 1 To UBound(veri1)

If veri1(x, 1) & veri2(x, 1) & veri3(x, 1) = ComboBox1.Text & ComboBox2.Text & ComboBox3.Text Then

If Not liste.Exists(veri4(x, 1)) Then
liste.Add veri4(x, 1), veri4(x, 1)

End If
End If
Next

If liste.Count > 0 Then
ComboBox4.List = liste.Keys
End If

End Sub



Private Sub ComboBox4_Click()
'TextBox1.Text = ""

veri1 = ""
veri2 = ""
'On Error Resume Next
Set sh1 = Sheets("Veriler")
deg1 = ""
For r = 2 To sh1.Cells(Rows.Count, "A").End(3).Row
If sh1.Cells(r, 1).Value & sh1.Cells(r, 2).Value & sh1.Cells(r, 3).Value & sh1.Cells(r, 4).Value = ComboBox1.Text & ComboBox2.Text & ComboBox3.Text & ComboBox4.Text Then

TextBox15.Text = sh1.Cells(r, 5)
TextBox4.Text = sh1.Cells(r, 6)

Exit For
End If
Next

'MsgBox "işlem tamam"


End Sub




Private Sub UserForm_Initialize()
CommandButton4.Enabled = False
ComboBox1.Clear

son = Sheets("Veriler").Cells(Rows.Count, 1).End(3).Row
veri = Sheets("Veriler").Range("A2:A" & son)

Set liste = CreateObject("Scripting.Dictionary")

For x = 1 To UBound(veri)
If Not liste.Exists(veri(x, 1)) Then liste.Add veri(x, 1), veri(x, 1)
Next
'TextBox1.Enabled = True
TextBox1.Text = Format(Now, "dd mmmm yyyy hh:mm:ss")

If liste.Count > 0 Then
ComboBox1.List = liste.Keys



  TextBox1.Enabled = True
    ListBox1.ColumnCount = 15
    ListBox1.ColumnHeads = False
    ListBox1.RowSource = "A1:O" & [d1004].End(1).Row
    ListBox1.ColumnWidths = "42;52;46;65;0;180;50;180;180;0;0;300;0;0;0"
    Dim rRange As Range


Application.ScreenUpdating = True
ActiveWorkbook.Save
End If
Label18 = WorksheetFunction.CountA(Sayfa1.[A2:A1048576])
Label20 = WorksheetFunction.CountA(Sayfa2.[A2:A1048576])
End Sub
İlk mesajdaki karakter sınırından kodu 2'ye bölmek durumunda kaldım
 

Necdet

Moderatör
Yönetici
Katılım
4 Haziran 2005
Mesajlar
15,359
Excel Vers. ve Dili
Ofis 365 Türkçe
Merhaba,

Kodları dener misiniz?

Kod:
Private Sub CommandButton1_Click()

Dim ctrl As Control
Dim txt As String

For Each ctrl In Controls
    If TypeName(ctrl) = "ComboBox" Then
        If ctrl.Value = "" Then
            txt = txt & ", " & ctrl.Name
        End If
    End If
Next ctrl

If Not txt = "" Then
    MsgBox Mid(txt, 2) & " Değer Seçilmemiş..... "
    Exit Sub
End If

End Sub
 

serif_007

Altın Üye
Katılım
5 Nisan 2014
Mesajlar
155
Excel Vers. ve Dili
Excel 2019
Altın Üyelik Bitiş Tarihi
16-07-2027
Merhaba,

Kodları dener misiniz?

Kod:
Private Sub CommandButton1_Click()

Dim ctrl As Control
Dim txt As String

For Each ctrl In Controls
    If TypeName(ctrl) = "ComboBox" Then
        If ctrl.Value = "" Then
            txt = txt & ", " & ctrl.Name
        End If
    End If
Next ctrl

If Not txt = "" Then
    MsgBox Mid(txt, 2) & " Değer Seçilmemiş..... "
    Exit Sub
End If

End Sub
Necdet bey merhaba. Yardımınız için teşekkür ederim fakat yine listeye ekleme yapıyor ve Combobox1 ve Combobox2 dolu 3,4,5 boş olmasına rağmen 1,2,3,4,5 değer seçilmemiştir şeklinde mesaj veriyor.
 

Necdet

Moderatör
Yönetici
Katılım
4 Haziran 2005
Mesajlar
15,359
Excel Vers. ve Dili
Ofis 365 Türkçe
exit sub ile koddan çıkması gerek
 

serif_007

Altın Üye
Katılım
5 Nisan 2014
Mesajlar
155
Excel Vers. ve Dili
Excel 2019
Altın Üyelik Bitiş Tarihi
16-07-2027
exit sub ile koddan çıkması gerek
Necdet bey çok teşekkür ederim. Kodu ekleyeceğim satır aralığını gözden kaçırmışım şimdi düzelttim oldu. Peki Her Combobox için farklı mesaj verdirebilmemiz mümkün müdür? Programı benden başka birçok arkadaşım kullanıyor anlayamayacakları kesin. Örneğin Combobox1 İl seçiminin yapıldığı Combobox. İl seçilmediğinde Combobox1 değer girilmemiş yerine İl seçimi yapmadınız şeklinde uyarı verse. Ya da şöyle de olabilir Combobox karşısındaki Label'da yazan yazıyı yazabilmesi de olabilir.
Not: Combobox isimlerini değiştirerek istediğim sonuca ulaştım. çok teşekkürler
 
Son düzenleme:
Üst