Skip to main content

AccessTr.neT


Listboxda Sayfa İsimlerini Filtreleme

Listboxda Sayfa İsimlerini Filtreleme

#4
dilerim aşağıdaki kodlar işinize yarar
modül başlangıcına eklenecek kodlar
Option Compare Text
Const Ekleme As String = "|ŞABLON|Sayfa1|liste|"
UserForm_Initialize kodu
Private Sub UserForm_Initialize()
Dim syf As Worksheet, k As Byte

Me.ListBox1.Clear

'ListBox veri ekle'
For Each syf In Worksheets
If InStr(1, Ekleme, "|" & syf.Name & "|", 1) = 0 Then ListBox1.AddItem syf.Name
Next syf
listeSirala
End Sub
TextBox1_Change kodu
Private Sub TextBox1_Change()
Dim syf As Worksheet, k As Byte
Me.ListBox1.Clear
For Each syf In Worksheets
'ListBox daki listeyi görüntüleme'
' If InStr(1, Ekleme, "|" & syf.Name & "|", 1) = 0 And InStr(1, syf.Name, Me.TextBox1.Text) > 0 Then ListBox1.AddItem syf.Name
If InStr(1, Ekleme, "|" & syf.Name & "|", 1) = 0 And syf.Name Like "*" & Me.TextBox1.Text & "*" Then ListBox1.AddItem syf.Name
Next syf
listeSirala
End Sub
Sıralama fonksiyonu
Sub listeSirala()
Dim vaItems As Variant
Dim i As Long, j As Long
Dim vTemp As Variant

'Put the items in a variant array
vaItems = Me.ListBox1.List

'Steal code from John Walkenbach’s Excel Power Programming
'with Vba to sort the array
For i = LBound(vaItems, 1) To UBound(vaItems, 1) - 1
For j = i + 1 To UBound(vaItems, 1)
If vaItems(i, 0) > vaItems(j, 0) Then
vTemp = vaItems(i, 0)
vaItems(i, 0) = vaItems(j, 0)
vaItems(j, 0) = vTemp
End If
Next j
Next i

'Clear the listbox
Me.ListBox1.Clear

'Add the sorted array back to the listbox
For i = LBound(vaItems, 1) To UBound(vaItems, 1)
Me.ListBox1.AddItem vaItems(i, 0)
Next i
End Sub
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
Listboxda Sayfa İsimlerini Filtreleme - Yazar: m_demir - 10/05/2020, 18:49
RE: Listboxda Sayfa İsimlerini Filtreleme - Yazar: berduş - 11/05/2020, 01:55
Task