• DİKKAT

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

userformdaki textboxların toplamını alma

kemal turan

Altın Üye
Katılım
10 Haziran 2011
Mesajlar
1,677
Excel Vers. ve Dili
Excel 2010 32 bit
userformda bulunan textboxlara listbox un "clik" olayına bağlı değerleri getiriyoruz.
her türlü formatı denedim abuk subuk sonuçlar veriyor.
textbox 64-84 arası değerleri textbox 86 ya almak istiyorum.
Teşekkür ederim.
 

Ekli dosyalar

Merhaba.
Test etmek için CARİLER formuna üç tane TextBox ve bir CommandButton ekledim.
CommanButton_Clik olayına ise TextBox4 = TextBox2 * TextBox3 kod satırını yazdım.
Formu çalıştırıp TextBox2 ve TextBox3'e sayısal değer yazıp, CommanButton'a tıkladığımda sonuç aldım.
Format kodu kullanmadan bu şekilde sonuç alınabiliyor.
 
Son düzenleme:
Ömer bey merhaba,
Yatay olarak çarpma işlemlerini yapan textboxlarda sorun vardı forumdan araştırarak format ile çözebildim.
bu toplama işini çözemedim.
userform içerisindeki birim fiatlarının bulunduğu 2 nci sutun listbox formatından kaynaklanıyor olabilirmi ?
veya;
textbox86.value= val(textbox64.value)+.....kod satırını başka bir olaya mı bağlamak lazım.
Teşekkür ederim.
 
Sn.SABAN Bey merhaba,
Şimdiye kadar hiç dosya eklemedim.
Sizin için listbox "Click" olayını vereyim.
Kod:
Private Sub ListBox1_Click()
On Error Resume Next
    a = ListBox1.Column(0) 'ünite
    B = ListBox1.Column(1) 'per
    
    For i = 0 To 21
    If Controls("Textbox" & 1 + i).Value = a Then Exit Sub ' 100 ilk textbox
    
    If Controls("Textbox" & 1 + i).Value = "" Then ' 100 ilk textbox
        Controls("Textbox" & 1 + i).Value = a ' 100 ilk textbox
        Controls("Textbox" & 22 + i).Value = 1
        Controls("Textbox" & 43 + i).Value = B
        Controls("Textbox" & 64 + i).Value = B
    TextBox22.Value = Format(CDbl(TextBox22.Value), "##,##0.00")
    TextBox23.Value = Format(CDbl(TextBox23.Value), "##,##0.00")
    TextBox24.Value = Format(CDbl(TextBox24.Value), "##,##0.00")
    TextBox25.Value = Format(CDbl(TextBox25.Value), "##,##0.00")
    TextBox26.Value = Format(CDbl(TextBox26.Value), "##,##0.00")
    TextBox27.Value = Format(CDbl(TextBox27.Value), "##,##0.00")
    TextBox28.Value = Format(CDbl(TextBox28.Value), "##,##0.00")
    TextBox29.Value = Format(CDbl(TextBox29.Value), "##,##0.00")
    TextBox30.Value = Format(CDbl(TextBox30.Value), "##,##0.00")
    TextBox31.Value = Format(CDbl(TextBox31.Value), "##,##0.00")
    TextBox32.Value = Format(CDbl(TextBox32.Value), "##,##0.00")
    TextBox33.Value = Format(CDbl(TextBox33.Value), "##,##0.00")
    TextBox34.Value = Format(CDbl(TextBox34.Value), "##,##0.00")
    TextBox35.Value = Format(CDbl(TextBox35.Value), "##,##0.00")
    TextBox36.Value = Format(CDbl(TextBox36.Value), "##,##0.00")
    TextBox37.Value = Format(CDbl(TextBox37.Value), "##,##0.00")
    TextBox38.Value = Format(CDbl(TextBox38.Value), "##,##0.00")
    TextBox39.Value = Format(CDbl(TextBox39.Value), "##,##0.00")
    TextBox40.Value = Format(CDbl(TextBox40.Value), "##,##0.00")
    TextBox41.Value = Format(CDbl(TextBox41.Value), "##,##0.00")
    TextBox42.Value = Format(CDbl(TextBox42.Value), "##,##0.00")
    TextBox43.Value = Format(CDbl(TextBox43.Value), "##,##0.00")
    TextBox44.Value = Format(CDbl(TextBox44.Value), "##,##0.00")
    TextBox45.Value = Format(CDbl(TextBox45.Value), "##,##0.00")
    TextBox46.Value = Format(CDbl(TextBox46.Value), "##,##0.00")
    TextBox47.Value = Format(CDbl(TextBox47.Value), "##,##0.00")
    TextBox48.Value = Format(CDbl(TextBox48.Value), "##,##0.00")
    TextBox49.Value = Format(CDbl(TextBox49.Value), "##,##0.00")
    TextBox50.Value = Format(CDbl(TextBox50.Value), "##,##0.00")
    TextBox51.Value = Format(CDbl(TextBox51.Value), "##,##0.00")
    TextBox52.Value = Format(CDbl(TextBox52.Value), "##,##0.00")
    TextBox53.Value = Format(CDbl(TextBox53.Value), "##,##0.00")
    TextBox54.Value = Format(CDbl(TextBox54.Value), "##,##0.00")
    TextBox55.Value = Format(CDbl(TextBox55.Value), "##,##0.00")
    TextBox56.Value = Format(CDbl(TextBox56.Value), "##,##0.00")
    TextBox57.Value = Format(CDbl(TextBox57.Value), "##,##0.00")
    TextBox58.Value = Format(CDbl(TextBox58.Value), "##,##0.00")
    TextBox59.Value = Format(CDbl(TextBox59.Value), "##,##0.00")
    TextBox60.Value = Format(CDbl(TextBox60.Value), "##,##0.00")
    TextBox61.Value = Format(CDbl(TextBox61.Value), "##,##0.00")
    TextBox62.Value = Format(CDbl(TextBox62.Value), "##,##0.00")
    TextBox63.Value = Format(CDbl(TextBox63.Value), "##,##0.00")
    TextBox64.Value = Format(CDbl(TextBox64.Value), "##,##0.00")
    TextBox65.Value = Format(CDbl(TextBox65.Value), "##,##0.00")
    TextBox66.Value = Format(CDbl(TextBox66.Value), "##,##0.00")
    TextBox67.Value = Format(CDbl(TextBox67.Value), "##,##0.00")
    TextBox68.Value = Format(CDbl(TextBox68.Value), "##,##0.00")
    TextBox69.Value = Format(CDbl(TextBox69.Value), "##,##0.00")
    TextBox70.Value = Format(CDbl(TextBox70.Value), "##,##0.00")
    TextBox71.Value = Format(CDbl(TextBox71.Value), "##,##0.00")
    TextBox72.Value = Format(CDbl(TextBox72.Value), "##,##0.00")
    TextBox73.Value = Format(CDbl(TextBox73.Value), "##,##0.00")
    TextBox74.Value = Format(CDbl(TextBox74.Value), "##,##0.00")
    TextBox75.Value = Format(CDbl(TextBox75.Value), "##,##0.00")
    TextBox76.Value = Format(CDbl(TextBox76.Value), "##,##0.00")
    TextBox77.Value = Format(CDbl(TextBox77.Value), "##,##0.00")
    TextBox78.Value = Format(CDbl(TextBox78.Value), "##,##0.00")
    TextBox79.Value = Format(CDbl(TextBox79.Value), "##,##0.00")
    TextBox80.Value = Format(CDbl(TextBox80.Value), "##,##0.00")
    TextBox81.Value = Format(CDbl(TextBox81.Value), "##,##0.00")
    TextBox82.Value = Format(CDbl(TextBox82.Value), "##,##0.00")
    TextBox83.Value = Format(CDbl(TextBox83.Value), "##,##0.00")
    TextBox84.Value = Format(CDbl(TextBox84.Value), "##,##0.00")
    
    TextBox86.Value = Val(TextBox64.Value) + Val(TextBox65.Value) + Val(TextBox66.Value) + Val(TextBox67.Value) + Val(TextBox68.Value) + Val(TextBox69.Value) + Val(TextBox70.Value) + Val(TextBox71.Value) + Val(TextBox72.Value) + Val(TextBox73.Value) + Val(TextBox74.Value) + Val(TextBox75.Value) + Val(TextBox76.Value) + Val(TextBox77.Value) + Val(TextBox78.Value) + Val(TextBox79.Value) + Val(TextBox80.Value) + Val(TextBox81.Value) + Val(TextBox82.Value) + Val(TextBox83.Value) + Val(TextBox84.Value)
    TextBox86.Value = Format(Val(TextBox86.Value), "##,##0.00")
    Exit Sub
    End If
    Next

    If Controls("Textbox" & 1 + i).Value >= 1 Then
    MsgBox "SATIŞ SATIRI DOLDU"
    End If
End Sub
 
Aşağıdaki şekilde bir deneyeniz.

Kod:
Private Sub ListBox1_Click()
On Error Resume Next
    a = ListBox1.Column(0) 'ünite
    B = ListBox1.Column(1) 'per
    
    For i = 0 To 21
    If Controls("Textbox" & 1 + i).Value = a Then Exit Sub ' 100 ilk textbox
    
    If Controls("Textbox" & 1 + i).Value = "" Then ' 100 ilk textbox
        Controls("Textbox" & 1 + i).Value = a ' 100 ilk textbox
        Controls("Textbox" & 22 + i).Value = 1
        Controls("Textbox" & 43 + i).Value = B
        Controls("Textbox" & 64 + i).Value = B
    TextBox22.Value = Format(CDbl(TextBox22.Value), "##,##0.00")
    TextBox23.Value = Format(CDbl(TextBox23.Value), "##,##0.00")
    TextBox24.Value = Format(CDbl(TextBox24.Value), "##,##0.00")
    TextBox25.Value = Format(CDbl(TextBox25.Value), "##,##0.00")
    TextBox26.Value = Format(CDbl(TextBox26.Value), "##,##0.00")
    TextBox27.Value = Format(CDbl(TextBox27.Value), "##,##0.00")
    TextBox28.Value = Format(CDbl(TextBox28.Value), "##,##0.00")
    TextBox29.Value = Format(CDbl(TextBox29.Value), "##,##0.00")
    TextBox30.Value = Format(CDbl(TextBox30.Value), "##,##0.00")
    TextBox31.Value = Format(CDbl(TextBox31.Value), "##,##0.00")
    TextBox32.Value = Format(CDbl(TextBox32.Value), "##,##0.00")
    TextBox33.Value = Format(CDbl(TextBox33.Value), "##,##0.00")
    TextBox34.Value = Format(CDbl(TextBox34.Value), "##,##0.00")
    TextBox35.Value = Format(CDbl(TextBox35.Value), "##,##0.00")
    TextBox36.Value = Format(CDbl(TextBox36.Value), "##,##0.00")
    TextBox37.Value = Format(CDbl(TextBox37.Value), "##,##0.00")
    TextBox38.Value = Format(CDbl(TextBox38.Value), "##,##0.00")
    TextBox39.Value = Format(CDbl(TextBox39.Value), "##,##0.00")
    TextBox40.Value = Format(CDbl(TextBox40.Value), "##,##0.00")
    TextBox41.Value = Format(CDbl(TextBox41.Value), "##,##0.00")
    TextBox42.Value = Format(CDbl(TextBox42.Value), "##,##0.00")
    TextBox43.Value = Format(CDbl(TextBox43.Value), "##,##0.00")
    TextBox44.Value = Format(CDbl(TextBox44.Value), "##,##0.00")
    TextBox45.Value = Format(CDbl(TextBox45.Value), "##,##0.00")
    TextBox46.Value = Format(CDbl(TextBox46.Value), "##,##0.00")
    TextBox47.Value = Format(CDbl(TextBox47.Value), "##,##0.00")
    TextBox48.Value = Format(CDbl(TextBox48.Value), "##,##0.00")
    TextBox49.Value = Format(CDbl(TextBox49.Value), "##,##0.00")
    TextBox50.Value = Format(CDbl(TextBox50.Value), "##,##0.00")
    TextBox51.Value = Format(CDbl(TextBox51.Value), "##,##0.00")
    TextBox52.Value = Format(CDbl(TextBox52.Value), "##,##0.00")
    TextBox53.Value = Format(CDbl(TextBox53.Value), "##,##0.00")
    TextBox54.Value = Format(CDbl(TextBox54.Value), "##,##0.00")
    TextBox55.Value = Format(CDbl(TextBox55.Value), "##,##0.00")
    TextBox56.Value = Format(CDbl(TextBox56.Value), "##,##0.00")
    TextBox57.Value = Format(CDbl(TextBox57.Value), "##,##0.00")
    TextBox58.Value = Format(CDbl(TextBox58.Value), "##,##0.00")
    TextBox59.Value = Format(CDbl(TextBox59.Value), "##,##0.00")
    TextBox60.Value = Format(CDbl(TextBox60.Value), "##,##0.00")
    TextBox61.Value = Format(CDbl(TextBox61.Value), "##,##0.00")
    TextBox62.Value = Format(CDbl(TextBox62.Value), "##,##0.00")
    TextBox63.Value = Format(CDbl(TextBox63.Value), "##,##0.00")
    TextBox64.Value = Format(CDbl(TextBox64.Value), "##,##0.00")
    TextBox65.Value = Format(CDbl(TextBox65.Value), "##,##0.00")
    TextBox66.Value = Format(CDbl(TextBox66.Value), "##,##0.00")
    TextBox67.Value = Format(CDbl(TextBox67.Value), "##,##0.00")
    TextBox68.Value = Format(CDbl(TextBox68.Value), "##,##0.00")
    TextBox69.Value = Format(CDbl(TextBox69.Value), "##,##0.00")
    TextBox70.Value = Format(CDbl(TextBox70.Value), "##,##0.00")
    TextBox71.Value = Format(CDbl(TextBox71.Value), "##,##0.00")
    TextBox72.Value = Format(CDbl(TextBox72.Value), "##,##0.00")
    TextBox73.Value = Format(CDbl(TextBox73.Value), "##,##0.00")
    TextBox74.Value = Format(CDbl(TextBox74.Value), "##,##0.00")
    TextBox75.Value = Format(CDbl(TextBox75.Value), "##,##0.00")
    TextBox76.Value = Format(CDbl(TextBox76.Value), "##,##0.00")
    TextBox77.Value = Format(CDbl(TextBox77.Value), "##,##0.00")
    TextBox78.Value = Format(CDbl(TextBox78.Value), "##,##0.00")
    TextBox79.Value = Format(CDbl(TextBox79.Value), "##,##0.00")
    TextBox80.Value = Format(CDbl(TextBox80.Value), "##,##0.00")
    TextBox81.Value = Format(CDbl(TextBox81.Value), "##,##0.00")
    TextBox82.Value = Format(CDbl(TextBox82.Value), "##,##0.00")
    TextBox83.Value = Format(CDbl(TextBox83.Value), "##,##0.00")
    TextBox84.Value = Format(CDbl(TextBox84.Value), "##,##0.00")

[COLOR="Red"][B]For a = 64 to 84
Textbox86 = val(Textbox86) + val(Controls("Textbox" & a))
Next
TextBox86.Value = Format(TextBox86, "##,##0.00")[/B][/COLOR]


    Exit Sub
    End If
    Next

    If Controls("Textbox" & 1 + i).Value >= 1 Then
    MsgBox "SATIŞ SATIRI DOLDU"
    End If
End Sub

Dosya ekleme konusuna gelince, dosyanızı bir upload sitesine yükleyip (www.dosya.web.tr gibi) oradan verilen linki burada paylaşma olayıdır.
 
Aşağıdaki şekilde denermisiniz.
Kod:
Private Sub CommandButton1_Click()
For i = 64 To 84
If Controls("TextBox" & i) <> "" Then
a = Val(Controls("TextBox" & i))
toplam = toplam + a
End If
Next
TextBox86 = toplam
End Sub
 
Merhaba sn.Vardar
kod çalıştığı zaman en son textbox değerini gösterdi. Toplam almıyor .
Teşekkür ederim
 
Uyarladığınız şekli ile dosyayı eklermisiniz.
 
Sn.vardar ,
akşam aşağıdaki kodda (kırmızı renkli) kısmı ekledim.
Bu eklenen kısım bütün textboxlar dolduğunda doğru toplam alıyor.
Ben ürün eklendikçe textbox86 değerinin yenilenmesini istiyorum

Kod:
Private Sub ListBox1_Click()
On Error Resume Next
    a = ListBox1.Column(0) 'ünite
    B = ListBox1.Column(1) 'per
    
    For i = 0 To 21
    If Controls("Textbox" & 1 + i).Value = a Then Exit Sub
    
    If Controls("Textbox" & 1 + i).Value = "" Then
        Controls("Textbox" & 1 + i).Value = a
        Controls("Textbox" & 22 + i).Value = 1
        Controls("Textbox" & 43 + i).Value = B
        Controls("Textbox" & 64 + i).Value = B
    TextBox22.Value = Format(CDbl(TextBox22.Value), "##,##0.00")
    TextBox23.Value = Format(CDbl(TextBox23.Value), "##,##0.00")
    TextBox24.Value = Format(CDbl(TextBox24.Value), "##,##0.00")
    TextBox25.Value = Format(CDbl(TextBox25.Value), "##,##0.00")
    TextBox26.Value = Format(CDbl(TextBox26.Value), "##,##0.00")
    TextBox27.Value = Format(CDbl(TextBox27.Value), "##,##0.00")
    TextBox28.Value = Format(CDbl(TextBox28.Value), "##,##0.00")
    TextBox29.Value = Format(CDbl(TextBox29.Value), "##,##0.00")
    TextBox30.Value = Format(CDbl(TextBox30.Value), "##,##0.00")
    TextBox31.Value = Format(CDbl(TextBox31.Value), "##,##0.00")
    TextBox32.Value = Format(CDbl(TextBox32.Value), "##,##0.00")
    TextBox33.Value = Format(CDbl(TextBox33.Value), "##,##0.00")
    TextBox34.Value = Format(CDbl(TextBox34.Value), "##,##0.00")
    TextBox35.Value = Format(CDbl(TextBox35.Value), "##,##0.00")
    TextBox36.Value = Format(CDbl(TextBox36.Value), "##,##0.00")
    TextBox37.Value = Format(CDbl(TextBox37.Value), "##,##0.00")
    TextBox38.Value = Format(CDbl(TextBox38.Value), "##,##0.00")
    TextBox39.Value = Format(CDbl(TextBox39.Value), "##,##0.00")
    TextBox40.Value = Format(CDbl(TextBox40.Value), "##,##0.00")
    TextBox41.Value = Format(CDbl(TextBox41.Value), "##,##0.00")
    TextBox42.Value = Format(CDbl(TextBox42.Value), "##,##0.00")
    TextBox43.Value = Format(CDbl(TextBox43.Value), "##,##0.00")
    TextBox44.Value = Format(CDbl(TextBox44.Value), "##,##0.00")
    TextBox45.Value = Format(CDbl(TextBox45.Value), "##,##0.00")
    TextBox46.Value = Format(CDbl(TextBox46.Value), "##,##0.00")
    TextBox47.Value = Format(CDbl(TextBox47.Value), "##,##0.00")
    TextBox48.Value = Format(CDbl(TextBox48.Value), "##,##0.00")
    TextBox49.Value = Format(CDbl(TextBox49.Value), "##,##0.00")
    TextBox50.Value = Format(CDbl(TextBox50.Value), "##,##0.00")
    TextBox51.Value = Format(CDbl(TextBox51.Value), "##,##0.00")
    TextBox52.Value = Format(CDbl(TextBox52.Value), "##,##0.00")
    TextBox53.Value = Format(CDbl(TextBox53.Value), "##,##0.00")
    TextBox54.Value = Format(CDbl(TextBox54.Value), "##,##0.00")
    TextBox55.Value = Format(CDbl(TextBox55.Value), "##,##0.00")
    TextBox56.Value = Format(CDbl(TextBox56.Value), "##,##0.00")
    TextBox57.Value = Format(CDbl(TextBox57.Value), "##,##0.00")
    TextBox58.Value = Format(CDbl(TextBox58.Value), "##,##0.00")
    TextBox59.Value = Format(CDbl(TextBox59.Value), "##,##0.00")
    TextBox60.Value = Format(CDbl(TextBox60.Value), "##,##0.00")
    TextBox61.Value = Format(CDbl(TextBox61.Value), "##,##0.00")
    TextBox62.Value = Format(CDbl(TextBox62.Value), "##,##0.00")
    TextBox63.Value = Format(CDbl(TextBox63.Value), "##,##0.00")
    
    Exit Sub
    End If
    Next
    If Controls("Textbox" & 1 + i).Value >= 1 Then

    MsgBox "SATIŞ SATIRI DOLDU"
    End If
    [COLOR="Red"]For k = 64 To 84
    If Controls("Textbox" & 1 + k).Value <> "" Then
        TextBox86.Value = Format(CDbl(TextBox64.Value) + CDbl(TextBox65.Value) + CDbl(TextBox66.Value) + CDbl(TextBox67.Value) + CDbl(TextBox68.Value) + CDbl(TextBox69.Value) + CDbl(TextBox70.Value) + CDbl(TextBox71.Value) + CDbl(TextBox72.Value) + CDbl(TextBox73.Value) + CDbl(TextBox74.Value) + CDbl(TextBox75.Value) + CDbl(TextBox76.Value) + CDbl(TextBox77.Value) + CDbl(TextBox78.Value) + CDbl(TextBox79.Value) + CDbl(TextBox80.Value) + CDbl(TextBox81.Value) + CDbl(TextBox82.Value) + CDbl(TextBox83.Value) + CDbl(TextBox84.Value), "##,##0.00")

    Exit Sub
    End If
    Next k[/COLOR]
    
End Sub
 
Bu kodları denermisiniz.

kod:

Kod:
Private Sub CommandButton2_Click()
toplam = 0
For i = 64 To 84
If Controls("TextBox" & i) <> "" Then
toplam = toplam + Round(Controls("TextBox" & i), 2) * 1
End If
Next
TextBox86.Text = Format(CDbl(toplam), "##,##0.00")

End Sub

Private Sub TextBox64_Change()
CommandButton2_Click
End Sub
Private Sub TextBox65_Change()
CommandButton2_Click
End Sub
Private Sub TextBox66_Change()
CommandButton2_Click
End Sub
Private Sub TextBox67_Change()
CommandButton2_Click
End Sub

Private Sub TextBox68_Change()
CommandButton2_Click
End Sub

Private Sub TextBox69_Change()
CommandButton2_Click
End Sub

Private Sub TextBox70_Change()
CommandButton2_Click
End Sub
Private Sub TextBox71_Change()
CommandButton2_Click
End Sub

Private Sub TextBox72_Change()
CommandButton2_Click
End Sub

Private Sub TextBox73_Change()
CommandButton2_Click
End Sub
Private Sub TextBox74_Change()
CommandButton2_Click
End Sub
Private Sub TextBox75_Change()
CommandButton2_Click
End Sub
Private Sub TextBox76_Change()
CommandButton2_Click
End Sub
Private Sub TextBox77_Change()
CommandButton2_Click
End Sub

Private Sub TextBox78_Change()
CommandButton2_Click
End Sub

Private Sub TextBox79_Change()
CommandButton2_Click
End Sub

Private Sub TextBox80_Change()
CommandButton2_Click
End Sub
Private Sub TextBox81_Change()
CommandButton2_Click
End Sub

Private Sub TextBox82_Change()
CommandButton2_Click
End Sub

Private Sub TextBox83_Change()
CommandButton2_Click
End Sub

Private Sub TextBox84_Change()
CommandButton2_Click
End Sub

Private Sub TextBox85_Change()
CommandButton2_Click
End Sub

Private Sub TextBox86_Change()
CommandButton2_Click
End Sub
 
Merhaba Sn. Vardar,
Küsüratları toplamadığı için yanlış sonuç veriyor.
İlginize teşekkür ederim.
sonuca ulaşmaya az kaldı:)
 
Merhaba Sn.Halit hocam,
ÇoK teşekkür ederim.Emeğinize sağlık.
Sorun çözülmüştür.
Selametle Kalınız.
 
Son düzenleme:
Geri
Üst