Trying something new

N

Neuther

I'm not sure if it's possible but i would like to ask anyway. I am new
to excel but i'm having a fun time figuring stuff out, but this one
stumped me. What i want it to do is this, say i have a number in this
case 64, i want excel to take that number and when put something in a
differnt cell say A1 (another number) i want it to subtract 1 from 64
making it 63, i can get it to do this much but what i want after that
is if i delete the number in a1 and add another number i want it to
keep the number of 63 and subtract 1 more (62). I hope it make's
sence, what i want to do is get the "count" to work with only one cell.
 
F

Frank Kabel

Hi

this can (IMO) only be achieved by an event procedure (VBA) for the
specific worksheet. Lets assume that your starting umber is in B1 and
you enter values to subtract in A1. The VBA code would look like the
following

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Range("B1").Value = Range("B1").Value - Target.Value
End If
Application.EnableEvents = True
End Sub

Some comments to this code
- there is no check that you will only enter values in A1 (would result
in a runtime error)
- same is true for B2

HTH
Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top