Aşağıdaki kodlarla textbox'a girilen veriye göre arama yapılıyor. Bu arama metodunda optionbutton ile seçeceğimiz sütunlarda arama yaptırılacak şekilde düzenleyebilir mi?.
optionbutton1 "B" sütunu, optbt2 "C" sütunu, optbut3 "D" sütununda arama yaptırmak istiyorum.
Private Sub TextBox25_Change() 'VERI ARAMA'
Dim k As Range, adrs As String, j As Byte, a, sat As Long
ReDim myarr(1 To 18, 1 To 1)
If TextBox25.Text = "" Then
sat = ActiveSheet.Cells(65536, "A").End(xlUp).Row
ListBox1.RowSource = ComboBox1.Text & "!A2:S" & sat
Exit Sub
End If
Set s1 = Sheets("" & ComboBox1)
With s1
ListBox1.RowSource = ""
If .FilterMode Then .ShowAllData
Set k = .Range("A2:S65536").Find(TextBox25.Text & "*", , xlValues, xlWhole)
If Not k Is Nothing Then
adrs = k.Address
Do
a = a + 1
ReDim Preserve myarr(1 To 18, 1 To a)
For j = 1 To 18
myarr(j, a) = .Cells(k.Row, j + 1).Value
Next j
Set k = s1.Range("A2:S65536").FindNext(k)
Loop While Not k Is Nothing And k.Address <> adrs
ListBox1.Column = myarr
End If
End With
End Sub
optionbutton1 "B" sütunu, optbt2 "C" sütunu, optbut3 "D" sütununda arama yaptırmak istiyorum.
Private Sub TextBox25_Change() 'VERI ARAMA'
Dim k As Range, adrs As String, j As Byte, a, sat As Long
ReDim myarr(1 To 18, 1 To 1)
If TextBox25.Text = "" Then
sat = ActiveSheet.Cells(65536, "A").End(xlUp).Row
ListBox1.RowSource = ComboBox1.Text & "!A2:S" & sat
Exit Sub
End If
Set s1 = Sheets("" & ComboBox1)
With s1
ListBox1.RowSource = ""
If .FilterMode Then .ShowAllData
Set k = .Range("A2:S65536").Find(TextBox25.Text & "*", , xlValues, xlWhole)
If Not k Is Nothing Then
adrs = k.Address
Do
a = a + 1
ReDim Preserve myarr(1 To 18, 1 To a)
For j = 1 To 18
myarr(j, a) = .Cells(k.Row, j + 1).Value
Next j
Set k = s1.Range("A2:S65536").FindNext(k)
Loop While Not k Is Nothing And k.Address <> adrs
ListBox1.Column = myarr
End If
End With
End Sub