mir994stan
New Member
- Joined
- Jul 18, 2021
- Messages
- 42
- Office Version
- 2016
- Platform
- Windows
Hello everyone, i almost completed my workbook mission but i run into new problem, and i can t find solution anywhere on internet. So i decided to ask community for help. On one sheet i have userform which i use when i need to return amount of some matterial to main storage from production. Every product in my list have its own uniqe ID, and when i issue whole amount of that product all works perfect. But problem appears when i need to do issue of partial ammounts. For example: i have 500 units of some product and i need to issue today 300 units, and the couple days later i need to issue the rest, 200 units. I can t sum those ammounts in same row, that part is good and it all works like intended. I create 2 separate record with same ID and different ammounts or same depending on needs from production. The real problem is when guys from production needs to return certan amount of that product that they don t need any more. I created userform that when u enter ID in TextBox7 all data with that ID are shown in listbox. When u double click for wanted record u can change values of that record in textboxes. I do it all right, but values changes on all record that have same ID. My Question is: Is it possible to edit only record that is selected in listbox? Screenshot of workbook is in links below:
screen shot: Capture
As u can see i have two record with same ID (35) and i need to set value of record ID 35 in row 40 to zero but then i dbl clikc on that record in listbox and chage its value i change values on both records, bcs of the same ID.... can i somehow change only one record in that i select?
Any help is welcome. Thanks in advance!
If its of some good, i use this code to search for record on sheet with data:
Private Sub CommandButton8_Click()
'--------------------------------------------
Dim sh As Worksheet
Set sh = Sheets("Izdato")
Dim i As Long
Dim x As Long
Dim p As Long
Me.ListBox1.Clear
'code for header___________________________________________________________
Me.ListBox1.AddItem "ID"
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = "Broj kutije"
Me.ListBox1.List(ListBox1.ListCount - 1, 2) = "Naziv"
Me.ListBox1.List(ListBox1.ListCount - 1, 3) = "Kolicina"
Me.ListBox1.List(ListBox1.ListCount - 1, 4) = "JM"
Me.ListBox1.List(ListBox1.ListCount - 1, 5) = "Status"
Me.ListBox1.List(ListBox1.ListCount - 1, 6) = "Datum vracanja"
Me.ListBox1.List(ListBox1.ListCount - 1, 7) = "Napomena"
'__________________________________________________________________
'search code-------------------------------------------------------
For i = 1 To sh.Range("A" & Rows.Count).End(xlUp).Row
For x = 1 To Len(sh.Cells(i, 1))
p = Me.TextBox7.TextLength
If LCase(Mid(sh.Cells(i, 1), x, p)) = Me.TextBox7 And Me.TextBox7 <> "" Then
With Me.ListBox1
.AddItem sh.Cells(i, 1)
.List(ListBox1.ListCount - 1, 1) = sh.Cells(i, 2)
.List(ListBox1.ListCount - 1, 2) = sh.Cells(i, 3)
.List(ListBox1.ListCount - 1, 3) = sh.Cells(i, 4)
.List(ListBox1.ListCount - 1, 4) = sh.Cells(i, 5)
.List(ListBox1.ListCount - 1, 5) = sh.Cells(i, 10)
.List(ListBox1.ListCount - 1, 7) = sh.Cells(i, 13)
.List(ListBox1.ListCount - 1, 6) = sh.Cells(i, 9)
End With
End If
Next x
Next i
End Sub
screen shot: Capture
As u can see i have two record with same ID (35) and i need to set value of record ID 35 in row 40 to zero but then i dbl clikc on that record in listbox and chage its value i change values on both records, bcs of the same ID.... can i somehow change only one record in that i select?
Any help is welcome. Thanks in advance!
If its of some good, i use this code to search for record on sheet with data:
Private Sub CommandButton8_Click()
'--------------------------------------------
Dim sh As Worksheet
Set sh = Sheets("Izdato")
Dim i As Long
Dim x As Long
Dim p As Long
Me.ListBox1.Clear
'code for header___________________________________________________________
Me.ListBox1.AddItem "ID"
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = "Broj kutije"
Me.ListBox1.List(ListBox1.ListCount - 1, 2) = "Naziv"
Me.ListBox1.List(ListBox1.ListCount - 1, 3) = "Kolicina"
Me.ListBox1.List(ListBox1.ListCount - 1, 4) = "JM"
Me.ListBox1.List(ListBox1.ListCount - 1, 5) = "Status"
Me.ListBox1.List(ListBox1.ListCount - 1, 6) = "Datum vracanja"
Me.ListBox1.List(ListBox1.ListCount - 1, 7) = "Napomena"
'__________________________________________________________________
'search code-------------------------------------------------------
For i = 1 To sh.Range("A" & Rows.Count).End(xlUp).Row
For x = 1 To Len(sh.Cells(i, 1))
p = Me.TextBox7.TextLength
If LCase(Mid(sh.Cells(i, 1), x, p)) = Me.TextBox7 And Me.TextBox7 <> "" Then
With Me.ListBox1
.AddItem sh.Cells(i, 1)
.List(ListBox1.ListCount - 1, 1) = sh.Cells(i, 2)
.List(ListBox1.ListCount - 1, 2) = sh.Cells(i, 3)
.List(ListBox1.ListCount - 1, 3) = sh.Cells(i, 4)
.List(ListBox1.ListCount - 1, 4) = sh.Cells(i, 5)
.List(ListBox1.ListCount - 1, 5) = sh.Cells(i, 10)
.List(ListBox1.ListCount - 1, 7) = sh.Cells(i, 13)
.List(ListBox1.ListCount - 1, 6) = sh.Cells(i, 9)
End With
End If
Next x
Next i
End Sub