Worksheet Change to build product list
Hi all ; I'd like to build something useful IMO, any help would be
appreciated. As ever, for the record, I don't do proper VBA (Dim, Set,
whatever).
It's an invoice thingy. For starters, there's 2 sheets - "Input" (the
invoice form, in A2:Fx) and Sheet2 for the table of products & prices
(A2:Bx).
I'd like a Worksheet_Change for Input!C:C ("Item"), If Target.Column = 3
Then etc. When an item is entered, the code should check whether the item
already exists in Sheet2!A:A on the table sheet. If it does, it should pull
in the price from Sheet2!B:B to Target.Offset(0,1). If it doesn't, it should
run an input box ("How much is this item?") which then adds the item & price
to Sheet2!A:B.
I can kludge it to a point, but I'm fed up with doing that. Anyways, I know
I'll get stuck eventually since I can never get
Range("Sheet2!A_whatever").Value = Target.Value to work (i.e. writing from
the event sheet to another).
Posting what I have is pointless in the sense that none of you would ever
use anything so ugly, on the other hand it might give one or two a
much-needed chuckle at the near-end of a long week. I promise I'll try &
understand any replies.
TIA,
Andy
If Target.Column = 3 Then
'Trap DEL
If Target = "" Then Exit Sub
Range("Input!H1").Value = Target.Value
'I1 formula = "=IF(ISNA(MATCH(H1,Items,0)),0,1)"
If Range("I1") = 0 Then
MsgBox "New."
'Inputbox proc
Else
Application.EnableEvents = False
Target.Range("B1").FormulaR1C1 = "=VLOOKUP(RC[-1],Prices,2,False)"
Target.Range("B1").Value = Target.Range("B1").Value
Application.EnableEvents = True
End If
End If
|