We have 4000 different materials/equipment in our stock.
We use a VBA stock macro, integrated with a barcode scanner, to make all the stock process.
We summarize all the different materials/equipments to another workbook separately thanks to VBA codes (let's say Summary Workbook).
To see how many different pipes and how many meters of pipes we have in our stock, you should click "PIPES" sheet inside of Summary Workbook.
For "ELECTRICAL MATERIALS", "FLANGES", "FITTINGS", "ASSETS" and the nearly 20 other stock groups it is the same.
All the titles are separated and they are all the different pages as a list.
Also I list all the titles ("ELECTRICAL MATERIALS", "FLANGES", "FITTINGS", "ASSETS", "PIPES" etc.) to another sheet (let's say DATA Sheet).
The main idea is: Use this sheet as a data list.
All the above operations purpose is checking materials/equipment quantity easily and how many different products we have in our stock. But when you open the "Summary Workbook" it is complicated to check. Every stock group includes at least 150 different materials/equipment.
So I created another sheet in Summary Workbook and named it Main Sheet. Besides I created a textbox and a listbox in it.
I choose all the stock information inside of the DATA sheet from (A2:F4214) named them "DATA".
So when I choose the listbox on the main sheet, I transfer all the "DATA"'s using "ListFillRange" method.
I use 6 columns with headings.
1- Number
2- Barcode No.
3- Stock Group Name
4- Stock Name
5- Stock Quantity
6- Stock Measurement (Meter, Piece, Set, Liter etc.)
Code to use textbox as a Search Box:
Private Sub TextBox1_Change()
Dim i As Long
Me.TextBox1.Text = StrConv(Me.TextBox1.Text, 1)
Me.ListBox1.Clear
For i = 2 To Application.WorksheetFunction.CountA(Sayfa281.Range("D:D"))
a = Len(Me.TextBox1.Text)
If Sayfa281.Cells(i, 4).Value Like "*" & TextBox1.Text & "*" Then
Me.ListBox1.AddItem Sayfa281.Cells(i, 4).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 4) = Sayfa281.Cells(i, 4).Value
End If
Next i
End Sub
It gave:
Run time error '- 2147467259(80004005)':
Unspecified error.
When I click DEBUG, it shows Me.ListBox1.Clear
in yellow.
When I used above code inside of a userform it works, but in an Excel sheet it did not.
ListFillRange
and filling the list only from the textbox change event (even if you have to leave the list empty at the beginning)? If this does not help, I will try to dig deeper to see if I can find something that could be of help. – Noah BridgeListFillRange
area. It works but not the way we wanted. Actually when i deleted ListFillRange and then i wrote stock name to textbox; it just finds stock name.Not the other column heads. 1- Number 2- Barcode No. 3- Stock Group Name 5- Stock Quantity 6- Stock Measurement ( Meter, Piece, Set, Liter etc.) The other important thins is when i wrote a stock name to textbox , i show same product name side by side twice time inside of the listbox. – Emir GökbudakListFillRange
is no longer being used, the listbox's columns will have to be configured manually. The Multiple columns section in this bettersolutions.com page shows how to configure the columns. In essence, you need to set the listbox's column count to 6, set the column widths, and add a line to set each column value (like the line you currently have for column 4). You will also need to use.AddItem
without any parameter (as in the link). If this comment doesn't help, I'll try to write out the actual code and post it. – Noah Bridge