Solved

Adding in relative row

Posted on 2014-03-29
9
373 Views
Last Modified: 2014-04-06
Hi All,

I am using the type of code:

 "= Round(constants!AO" & i & ",constants!AP" & i & ")"

where I have many rows and need to keep track of what goes on in the relative row.


First I will explain just the simple problem and then in the end I need it in for the form above.

Simple problem:   using units, or apples, or whatever. (Really the units are irreverent).
All numbers in the simple problem occur in row 10.


Suppose Column A has 24 apples.  Column B has no Apples.  Total number of Apples is 24 in Column C.   Update.

Now suppose that we have 8 new apples in Column B so the total number of Apples in column C is 32.   Update.

Now Column A has 32 apples, Column B, again has no Apples, and the Total in Column C is 32 apples.   There are now 20 more applies in Column B.   Update

Now in Column A has 52 apples, Column B has nothing and the Total in Column C is 52. Update.

i would also like to know how to "reset" this so that it would evaluate to "zero" in all columns and be ready to receive more data.

Now,  this is all happening in one row and I need some mechanism so that it is this kind of form/notation so that this will update in whatever row it is referring to;

"= (constants!AO" & i & ",constants!AP" & i & ")"
0
Comment
Question by:BostonBob
9 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39964567
What you're saying can be achieved by putting in C10:
=A10 + B10
or
=SUM(A10, B10)

HTH,
Dan
0
 

Author Comment

by:BostonBob
ID: 39964777
Dan,

Please read my question again.  It is a tad bit more involved than that.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 39980609
Not sure I'm getting that right: Whenever an update of a cell in column B happens, it should be added to A and then reset to 0? And that should happen to any row, of course?
0
 

Author Comment

by:BostonBob
ID: 39980673
You got it.  

Let me finish your sentence just for clarity.

Whenever an update of a cell in column B happens, it should be added to A and then "B" should be reset to 0 or "" and get ready for the next iteration where something appears in B.  Repeat process.

And that should happen to any row, correct.

...and maybe let me add a bit more.  

Once column A + relative row is reset to 0 or "" then the whole thing should be reset so column A and column B + relative row is 0 or "" and ready for the next iteration.  

thanks
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Expert Comment

by:Faustulus
ID: 39980690
What is the work flow like?
When a value is entered in column B, you say, column A should be updated and B reset to zero. This would happen so fast that the user would feel Excel somehow failed to register his entry and repeat it. So, presumably, you wouldn't want the update to occur immediately. That raises the question of when you want it to occur.
0
 

Author Comment

by:BostonBob
ID: 39980781
It is all automated.  Mr. Computer will be fine with it.  Besides, it is not updating all that often. What  Qlemo has proposed is what I need. thanks!
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39980857
You probably need something like this

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count = 1 Then
        If Target.Column = 2 Then
            If Target <> 0 Then
                Target.Offset(, -1) = Target.Offset(, -1) + Target
            End If
        End If
    End If
End Sub


This should go in the worksheet module for that sheet
0
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 500 total points
ID: 39981062
need to reset the entered value as well.
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Count = 1 Then
        'only one cell updated
        If Target.Column = 2 Then
            'update is column B , our monitor target
            Target.Offset(0, -1).Value = Target.Offset(0, 1).Value
            Target.Value = 0
        End If
    End If
End Sub

Open in new window

the addition part of the worksheet can be omitted, then the update Target.Offset(0, -1).Value = Target.Offset(0, -1).Value   as saqib noted.

I have attached a test workbook to show you it works, but also a big caveat...
the Worksheet_Change event only triggers when a cell is manually changed.  Not if it is the result of a formula as shown in Row7.
update-1.xls
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now