Listbox ' ta tarih ve sayı formadı

Katılım
5 Eylül 2007
Mesajlar
1,247
Excel Vers. ve Dili
ofis 2010
Altın Üyelik Bitiş Tarihi
21-07-2024
iyi akşamlar; kullandığım kodda listboxta hem tarih ve hem de sayı formatı kullanmak gerekiyor.
Kod:
Private Sub UserForm_Initialize()
Dim z As Object, Liste()
If Sheets("I_TKP").AutoFilterMode Then Sheets("I_TKP").AutoFilterMode = False
Set z = CreateObject("Scripting.dictionary")
Liste = Sheets("I_TKP").Range("A2:A" & Sheets("I_TKP").Cells(Rows.Count, "A").End(xlUp).Row).Value
For i = 1 To UBound(Liste)
    If Not z.exists(Liste(i, 1)) Then
        z.Add Liste(i, 1), Nothing
    End If
Next i
If z.Count > 0 Then
    ComboBox1.List = Application.Transpose(Array(z.keys))
    ComboBox1.ListIndex = 0
End If
ListBox1.ColumnCount = 13
ListBox1.ColumnWidths = "112;65;60;55;1;70;70;1;50;50;50;70;1"
Call listele
'ListBox1.RowSource = "I_TKP!A2:G" & Sheets("I_TKP").Range("A65536").End(xlUp).Row
ListBox1.ColumnHeads = True ' ilk satır başlık

For i = 0 To ListBox1.ListCount - 1
    For k = 2 To ListBox1.ColumnCount - 1
        'ListBox1.List(i, k) = Format(ListBox1.List(i, k), "#,##0.00")
        ListBox1.List(i, k) = Format(ListBox1.List(i, k), "dd.mm.yyyy")
    Next
     
    Next


End Sub
Sub listele()
Dim s1 As Worksheet, s2 As Worksheet, sonsat2 As Long, myarr()
Dim i As Long, Liste()
ListBox1.RowSource = Empty
Set s1 = Sheets("I_TKP")
Set s2 = Sheets("Suz")
s2.Range("A2:m" & Rows.Count).Clear
If s1.AutoFilterMode Then s1.AutoFilterMode = False
s1.Range("A2").AutoFilter field:=1, Criteria1:=ComboBox1.Value & "*"
s1.Range("A2").CurrentRegion.Offset(1, 0).Copy s2.Range("A2")
s2.DrawingObjects.Delete
s1.AutoFilterMode = False
sonsat2 = s2.Cells(Rows.Count, "A").End(xlUp).Row
Liste = s2.Range("A2:m" & sonsat2)
ReDim myarr(1 To 13, 1 To sonsat2)
For i = 1 To UBound(Liste)
    myarr(1, i) = Liste(i, 1)
    myarr(2, i) = Liste(i, 2) 'Format(Liste(i, 2), "dd.mm.yyyy")
    myarr(3, i) = Liste(i, 3)
    myarr(4, i) = Liste(i, 4)
    myarr(5, i) = Liste(i, 5)
    myarr(6, i) = Liste(i, 6)
    myarr(7, i) = Liste(i, 7)
    myarr(8, i) = Liste(i, 8)
    myarr(9, i) = Liste(i, 9)
    myarr(10, i) = Liste(i, 10)
    myarr(11, i) = Liste(i, 11)
    myarr(12, i) = Liste(i, 12)
    myarr(13, i) = Liste(i, 13)
Next i
If UBound(Liste) > 0 Then ListBox1.Column = myarr
End Sub
Kod:
For i = 0 To ListBox1.ListCount - 1
    For k = 2 To ListBox1.ColumnCount - 1
        'ListBox1.List(i, k) = Format(ListBox1.List(i, k), "#,##0.00")
        ListBox1.List(i, k) = Format(ListBox1.List(i, k), "dd.mm.yyyy")
    Next
ikisinden birini aktif edemiyorum. ikisin birden kullanmak için nasıl bir düzenleme yapmam gerekiyor. Teşekkürler
 
Son düzenleme:

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,853
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
Bunu bir dene

Kod:
For i = 0 To ListBox1.ListCount - 1
    For k = 2 To ListBox1.ColumnCount - 1

        If IsNumeric(ListBox1.List(i, k)) = True Then
        
            If IsDate(ListBox1.List(i, k)) = True And Len(ListBox1.List(i, k)) = 10 Then
            ListBox1.List(i, k) = Format(ListBox1.List(i, k), "dd.mm.yyyy")
            Else
            ListBox1.List(i, k) = Format(ListBox1.List(i, k), "#,##0.00") [COLOR="Red"]* 1[/COLOR]
            End If
        
        Else
        ListBox1.List(i, k) = Format(ListBox1.List(i, k), "#,##0.00")
        End If
    
    Next
Next
 
Katılım
5 Eylül 2007
Mesajlar
1,247
Excel Vers. ve Dili
ofis 2010
Altın Üyelik Bitiş Tarihi
21-07-2024
hata kodu verdi

Hata kodu verdi
 

Ekli dosyalar

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,853
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
kırmızı yeri silin
 
Üst