Hello,
I´m currently facing the problem, that my VBA program doesn´t work as I wish it would. I have between 2- x materials in 'List_Mat' (Material 100520, 100620, 100658, ...) (unlimited number of materials). These materials are the raw materials of products of which some information should be shown in the listbox 'List_Into'- one raw material can be used for multiple products and therefore with the selection of one raw material, multiple material should be listed in 'List_Into'. The material numbers are saved in the table "Stammdaten" in column K. Now I would like to click on one of the raw materials in listbox 'List_Mat' and than all products which are based on the selected raw material should be shown in listbox 'List_Mat'.
So far I have the following code:
Dim x As Variant Dim List1Auswahl As String Dim z As Variant Dim y As Variant
List1Auswahl = UserForm1.List_Mat.List(List_Mat.ListIndex) z = ThisWorkbook.Worksheets("Stammdaten").Columns("K:K").Find(List1Auswahl, LookIn:=xlValues).Row
y = z Do y = y + 2 Loop While ThisWorkbook.Worksheets("Stammdaten").Cells(y, 2) = "" And Not ThisWorkbook.Worksheets("Stammdaten").Cells(y, 5) = ""
For x = z To y If ThisWorkbook.Worksheets("Stammdaten").Cells(x, 3) <> "" Then With UserForm1.List_Into
.ColumnCount = 4 .ColumnWidths = "100;100;100;100" .AddItem .List(List_Into.ListCount - 1, 0) = Sheets("Stammdaten").Cells(x, 1) .List(List_Into.ListCount - 1, 1) = Sheets("Stammdaten").Cells(x, 2) .List(List_Into.ListCount - 1, 2) = Sheets("Stammdaten").Cells(x, 5) .List(List_Into.ListCount - 1, 3) = Sheets("Stammdaten").Cells(x, 4)
'.AddItem ThisWorkbook.Worksheets("Stammdaten").Cells(x, 3).Value
End With End If Next x
I appreciate your help.
I´ve tried to use different codes but nothing worked so far.
Bookmarks