View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
[email protected] joone@hotmail.com is offline
external usenet poster
 
Posts: 6
Default Need Help with Macro

Bob,
Your code is actually working great for me. I just have one request, I
wanted to add a cell where I can actually add to the Balance Inventory. So
Basically Column D is to add to Column B.

Thanks in advance.

COL A: Items
A1: "Item 1"
A2: "Item 2"
A3: "Item 3"

COL B: Current Balance
B1: "100"
B2: "150"
B3: "205"

COL C: USED
C1:
C2:
C3:

COL D: RESTOCK
D1:
D2:
D3:



"Bob Phillips" wrote:

No, you can't have a formula and a value in a cell, so it has to be VBA.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

" wrote in
message ...
Thanks for your response Bob. Unfortunately, I'm not really proficient at
this so I can't apply it to my spreadsheet. I thought I did what you told
me
to do but to no avail. Is there a formula I can use instead of Macro.
Say:
A1 is the current balance. If I input a number on A2 (Used), A1 is
automatically updated with the current balance (meaning A2 is
automatically
subracted from A1).

Thanks again.


"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C:C" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If IsNumeric(.Value) Then
If IsNumeric(.Offset(0, -1).Value) Then
.Offset(0, -1).Value = .Offset(0, -1).Value - .Value
.Value = ""
End If
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

" wrote
in
message ...
COL A: Items
A1: "Item 1"
A2: "Item 2"
A3: "Item 3"

COL B: Current Balance
B1: "100"
B2: "150"
B3: "205"

COL C: USED
C1:
C2:
C3:

I need a Macro wriiten to subtract Column C from Column B; update
Column B
of the current balance and delete the number used at column C as soon
as
the
current balance is updated.

I hope I'm clear with my request. Thanks in advance.