Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subtract item from text box

Status
Not open for further replies.

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
 
As the value of a Text box is text, you should convert to numeric data with Val(txtQty) or Val(Me.txtQty.Value).

A.C.
 
at the momnt it wrx fine w/o that. if i didnt explain properly before the current problem is that it subtracts th number away from the first row only, no matter wot i double click
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top