17/04/2021, 01:06
feraz
Alttaki gibide biraz daha kod kısa olur.
Private Sub CommandButton16_Click()
Dim y As Byte, bulbaslikVeri As Range, bulveri As Range
Dim i As Long, deger As String
Dim syfVeri As Worksheet: Set syfVeri = ThisWorkbook.Sheets("VERÝ")
Dim syftasar As Worksheet: Set syftasar = ThisWorkbook.Sheets("TASARI")
With syftasar
.Range(.Cells(1, 6), .Cells(Rows.Count, Columns.Count)).ClearContents
y = 6
For x = 6 To 14
deger = Me.Controls("ComboBox" & x).Value
If Trim(deger) <> "" Then
.Cells(1, y).Value = deger
i = 2
Do While .Cells(i, 2).Value <> ""
Set bulveri = syfVeri.Columns(2).Find(.Cells(i, "B").Value, , xlValues, 1)
Set bulbaslikVeri = syfVeri.Rows(1).Find(deger, , , , 1)
If Not bulbaslikVeri Is Nothing Then _
.Cells(i, y).Value = syfVeri.Cells(bulveri.Row, bulbaslikVeri.Column)
i = i + 1
Loop
y = y + 1
End If
Next x
End With
syftasar.Cells.EntireColumn.AutoFit
syftasar.Cells.EntireRow.AutoFit
Set bulbaslikVeri = Nothing: Set bulveri = Nothing
Set syfVeri = Nothing: Set syftasar = Nothing
End Sub