Guest_imported
New member
- Jan 1, 1970
- 0
hallo, its me again, with the old problem but slightly different.
i have a listbox, whos source is a table of items, and some details, including the 'qty in stock' (in the 5th column).
i want a user to enter a value ina text box and dubble clik an item from the listbox
th item selected will be put onto a cell on a new sheet, th value in the text box will also be added and this works fine. however i also want it to chk th source for the item that is selected move five columns across and subtract th value in the text box from the cell that is selected (5 columns across from th selected item in the source). here is my current code with the bit i think needs to be changed in bold:
Sub lstItems_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With Worksheets("Invoice".Range("d65536".End(xlUp)
If .Address = "$d$3" And IsEmpty(.Value) Then
.Value = Me.lstItems.Value
Else: .Offset(1, 0).Value = Me.lstItems.Value
End If
End With
With Range(lstItems.RowSource).Cells(ListIndex + 1, 5)
.Value = .Value - txtQty
End With
With Worksheets("Invoice".Range("g22".End(xlUp)
If .Address = "$g$3" And IsEmpty(.Value) Then
.Value = Me.txtQty.Value
Else: .Offset(1, 0).Value = Me.txtQty.Value
End If
End With
End Sub
i have a listbox, whos source is a table of items, and some details, including the 'qty in stock' (in the 5th column).
i want a user to enter a value ina text box and dubble clik an item from the listbox
th item selected will be put onto a cell on a new sheet, th value in the text box will also be added and this works fine. however i also want it to chk th source for the item that is selected move five columns across and subtract th value in the text box from the cell that is selected (5 columns across from th selected item in the source). here is my current code with the bit i think needs to be changed in bold:
Sub lstItems_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With Worksheets("Invoice".Range("d65536".End(xlUp)
If .Address = "$d$3" And IsEmpty(.Value) Then
.Value = Me.lstItems.Value
Else: .Offset(1, 0).Value = Me.lstItems.Value
End If
End With
With Range(lstItems.RowSource).Cells(ListIndex + 1, 5)
.Value = .Value - txtQty
End With
With Worksheets("Invoice".Range("g22".End(xlUp)
If .Address = "$g$3" And IsEmpty(.Value) Then
.Value = Me.txtQty.Value
Else: .Offset(1, 0).Value = Me.txtQty.Value
End If
End With
End Sub