View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
jlig via OfficeKB.com jlig via OfficeKB.com is offline
external usenet poster
 
Posts: 2
Default AfterUpdate Code to Subtract Column (L) from (G)

Thanks for the reply..
I tried the code..get Compile Error: Variable not defined?

I then tried adding in Dim isect = String but get Compile Error: Object
Required?

I'm using Excel 2007 and have Macros/VB code allowed..
Thanks..
jlig

Per Jessen wrote:
Hi

It should work if your code is placed in the code sheet for ThisWorkbook.
But only for changes in L2.

As I suppose you only want this function on one sheet, I suggest you use a
Worksheet_Change event, which is to be placed in the code sheet for the
desired worksheet.

The solution below work on changes in L2:L100:

Private Sub Worksheet_Change(ByVal Target As Range)
Set isect = Intersect(Target, Range("L2:L100"))
If Not isect Is Nothing Then
TargetRow = Target.Row
Range("G" & TargetRow) = Range("G" & TargetRow) - Range("L" & TargetRow)
End If
End Sub

Hopes this helps.

---
Per

- Column L is the sold column.
- Column G is the Remaining Qty in Stock.

[quoted text clipped - 16 lines]
Thanks,
jlig


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200906/1