Tracking cell values...?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need cells linked together based on their values.
I've made up the following scenario:
select a cell (e.g. C4); invoke a macro which decremets the value in C4 by
one; another cell (e.g. A2) is somehow 'linked' to C4 and so is decremented
by one as well; that's it.
My requests are:
1. Could someone please hint me to the code to do this (I'm thinking in C
and assembly, which is unfortunate for this task of course)
2. I'll have more of such links throughout my worksheet, so the perfect
solution would be to store each cell's link to its 'custom property' so that
the macro code would only read the cell clicked and from its properties see
what other cells should be afected; hope I'm making myself clear... Is this
possible somehow?
 
All you have to do is put in the link cell =C4. You can manuals do theis on
the worksheet or do it by VBA

Range("A1") = "=C4"

or

Range("A1").formula = "=C4"

I don't see any difference with C Language, Basic, or Assembly Language. I
have over 25 years of writing code in all three languagges plus Fortran and
Pascal. I have writen assembly language proably in 10 diffferent assembly
languages.
 
Further to other answers to reduce the value of a cell by 1 whenever it is
selected try this. Right click the shet tab, view code and paste in

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1,B1,C1")) Is Nothing Then 'Change to suit
If IsNumeric(Target) Then
Application.EnableEvents = False
Target = Target - 1
Application.EnableEvents = True
End If
End If
End Sub

Mike
 
Gretát, thanks! It is not working yet, though, but I guess it's my fault in
putting the code into the worksheet...
How about the second part of my request - can you think of a way to put the
'linked cells' info somewhere into a cell (as a string, perhaps)? Is there
something like a custom property of a cell that could be used for this?
 

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

Back
Top