First of all a warning that I am a very big noob with excel vba, but here is a quick explanation of the thing I am working on and where I'm stuck with it.
I need to make a inventory system where users can get information about the software that is in use, add a (new) software and or update already existing software information. I followed tutorial and actually made something half decent (but definitely not done yet), I made a form that automatically pops up when the user opens the excel file, and a second form would open if someone would want to add a application with a control feature witch only adds the application if specific textboxes have been filled in.
so this is the problem, on the first page I have a Listbox with all the applications and a bunch of textboxes, I want that if I select something from the listbox, that the textboxes get filled in with data I have collected in a Master sheet.
so just like in this video @ 2:40
or (search this title: " Inventory Management Template For Store" from the channel "PK: An Excel Expert" if you don't trust clicking links from strangers) I would like that functionality but I don't understand it well enough for it to work with my file.
this is the script from that userform after I tried a bunch of staff but failed:
Option Explicit
Private Sub ListBox1_alleapp_Change()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("DATABASE1")
End Sub
Private Sub Textbox1_change()
Call Show_Product
End Sub
Private Sub UserForm_Activate()
Call Show_Product
End Sub
Sub Show_Product()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("DATABASE1")
Dim i As Integer
Me.ListBox1_alleapp.Clear
For i = 2 To Application.WorksheetFunction.CountA(sh.Range("B:B"))
If Me.TextBox1.Value = "" Then
Me.ListBox1_alleapp.AddItem sh.Range("B" & i).Value
Else
If InStr(sh.Range("B" & i).Value, Me.TextBox1.Value) > 0 Then
Me.ListBox1_alleapp.AddItem sh.Range("B" & i).Value
End If
End If
Next i
End Sub
Private Sub CommandButton5_Click()
UserForm1.Show
End Sub
I need to make a inventory system where users can get information about the software that is in use, add a (new) software and or update already existing software information. I followed tutorial and actually made something half decent (but definitely not done yet), I made a form that automatically pops up when the user opens the excel file, and a second form would open if someone would want to add a application with a control feature witch only adds the application if specific textboxes have been filled in.
so this is the problem, on the first page I have a Listbox with all the applications and a bunch of textboxes, I want that if I select something from the listbox, that the textboxes get filled in with data I have collected in a Master sheet.
so just like in this video @ 2:40
this is the script from that userform after I tried a bunch of staff but failed:
Option Explicit
Private Sub ListBox1_alleapp_Change()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("DATABASE1")
End Sub
Private Sub Textbox1_change()
Call Show_Product
End Sub
Private Sub UserForm_Activate()
Call Show_Product
End Sub
Sub Show_Product()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("DATABASE1")
Dim i As Integer
Me.ListBox1_alleapp.Clear
For i = 2 To Application.WorksheetFunction.CountA(sh.Range("B:B"))
If Me.TextBox1.Value = "" Then
Me.ListBox1_alleapp.AddItem sh.Range("B" & i).Value
Else
If InStr(sh.Range("B" & i).Value, Me.TextBox1.Value) > 0 Then
Me.ListBox1_alleapp.AddItem sh.Range("B" & i).Value
End If
End If
Next i
End Sub
Private Sub CommandButton5_Click()
UserForm1.Show
End Sub