Updating cells from data put into another cell - same sheet

Excel 2007

Have a number of columns I need automatically updated when inserting a value into Col i which is a summed value from

amounts in Col G.
Here's what I need to happen when the amount from col G is summed into Col i:

- duplicate that amount in Col U
- input 1.4 into Col V
- adjust col V's amount by multiplying it times 5% and put that adjusted amount in Col W
- add col V to col W and insert that sum into Col X
- take Col U's value divide it by Col X's value and insert that figure into Col Y
- take Col Y multiply it by 7.5% and put that value into Col Z
- take Col Y's value and apply this formula to it: =IF(Y547*7.5%<75, Y547-75, Y547-(Y547*7.5%)) and
insert that Value into Col T
- Finally, in Col S, input EUR

Attached is an example spreadsheet that does just that but only by pull-down copying. Book4.xls
JaseSAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SiddharthRoutCommented:
>>>Here's what I need to happen when the amount from col G is summed into Col i:

You mean H into I?

Sid
0
JaseSAuthor Commented:
That's correct. Sorry.
0
SiddharthRoutCommented:
Ok. Gimme few moments.

Sid
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

SiddharthRoutCommented:
Is this what you want?

Sample attached?

Code Used

    Dim rng As Range, aCell As Range
    Dim i As Long
    
    If Not Intersect(Target.Dependents, Columns(9)) Is Nothing Then
        Application.EnableEvents = False
        For Each rng In Range(Target.Dependents.Address)
            If rng.Column = 9 Then
                i = Range(rng.Address).Row
                Range("U" & i).Formula = "=" & rng.Address
                Exit For
            End If
        Next rng
        
        If i = 0 Then Exit Sub
        Range("V" & i).Value = 1.4
        Range("W" & i).Formula = "=" & Range("V" & i).Address & "*5%"
        Range("X" & i).Formula = "=" & Range("V" & i).Address & "+" & Range("W" & i).Address
        Range("Y" & i).Formula = "=" & Range("U" & i).Address & "/" & Range("X" & i).Address
        Range("Z" & i).Formula = "=" & Range("Y" & i).Address & "*7.5%"
        Range("T" & i).Formula = "=IF(Y" & i & "*7.5%<75, Y" & i & "-75, Y" & i & "-(Y" & i & "*7.5%))"
        Range("S" & i).Value = "EUR"
        Application.EnableEvents = True
    End If
End Sub

Open in new window



Book4.xls
0
JaseSAuthor Commented:
when I past values in Col H, which I must do - it verifies or corrects the actual amounts received from Col G, I get an error with the below highlighted in yellow:

If Not Intersect(Target.Dependents, Columns(9)) Is Nothing Then

See attached error
0
SiddharthRoutCommented:
Yes that is because there is no formula in Column I

Try this

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range, aCell As Range
    Dim i As Long
    
    On Error Resume Next
    If Not Intersect(Target.Dependents, Columns(9)) Is Nothing Then
        Application.EnableEvents = False
        For Each rng In Range(Target.Dependents.Address)
            If rng.Column = 9 Then
                i = Range(rng.Address).Row
                Range("U" & i).Formula = "=" & rng.Address
                Exit For
            End If
        Next rng
        
        If i = 0 Then Exit Sub
        Range("V" & i).Value = 1.4
        Range("W" & i).Formula = "=" & Range("V" & i).Address & "*5%"
        Range("X" & i).Formula = "=" & Range("V" & i).Address & "+" & Range("W" & i).Address
        Range("Y" & i).Formula = "=" & Range("U" & i).Address & "/" & Range("X" & i).Address
        Range("Z" & i).Formula = "=" & Range("Y" & i).Address & "*7.5%"
        Range("T" & i).Formula = "=IF(Y" & i & "*7.5%<75, Y" & i & "-75, Y" & i & "-(Y" & i & "*7.5%))"
        Range("S" & i).Value = "EUR"
        Application.EnableEvents = True
    End If
    On Error GoTo 0
End Sub

Open in new window


Sid
0
JaseSAuthor Commented:
uhhh.... nothing happens.
FYI: I sum col H into i: =SUM(H13:H23)

but when I do that, nothing happens
0
SiddharthRoutCommented:
You have to change the value in Col H for the macro to run.

Sid
0
JaseSAuthor Commented:
okay - but that is not the best because sometimes all the rows in H are not filled in so I have to wait until I get an amount to put into some rows in H. THEN, I sum the values from H into i and that is when I need the code to run. However, changing (pasting into H as I typically do) does nothing.
0
SiddharthRoutCommented:
Jase Here is what I did and it is working.

I created the formula first in Cell I13 and then copied and pasted the values into H13:H23

The macro ran just fine.

Sid
0
JaseSAuthor Commented:
Created the formula in i 13? Not sure why or what that is for.

Here's the way I need it to work:

- I paste amounts in Col H (H13 - H23 for example)
- Sum those amounts into Col i (i 13)which
- initiates the code and populates the rest of the row 13 as indicated above

As you can see the page is divided up into sections so each section would work as described.

Am I making sense?
0
SiddharthRoutCommented:
>>>Created the formula in i 13? Not sure why or what that is for.

Please see snapshot.

Sid
Untitled.jpg
0
JaseSAuthor Commented:
I'm sorry, but this one is just not working.
I've tried it your way by placing the formula in i 13 first, but it didn't do anything.
I tried it the way I need to do it which is paste in values in col H and then sum the values in col i and when it sums those to go ahead and kick off your code. However, in either way it is not working.

Now what?
0
SiddharthRoutCommented:
Another screencast coming up :)

Sid
0
SiddharthRoutCommented:
Ok I made a small change to the code. Now it is working when you paste the values in Col H. See the Yellow cells being populated.

Sample File attached.
.
Please see screencast.

Hope it helps.

Sid
SiddharthRout-441908.flv
Book4.xls
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JaseSAuthor Commented:
I just don't get it. I'm opening up your xls file and doing the same thing you are doing and it does nothing. Why would it work for you and not for me? I'm attaching a screen shot of the project panel and vb code so you can see if something is off with this. Update row vba
0
SiddharthRoutCommented:
Ok Do this.

Close Excel completely.
Open the file that I posted above
Paste this code in a module and run it

Sub Sample
application.screenupdating=true
end sub

Open in new window


Now try it.

Sid
ps: I might or might not be able to reply to your posts as Things are getting packed right now.
0
JaseSAuthor Commented:
we're getting closer. I did what you said and it works but only after I paste the values into col H, write the formula to sum in col i, delete the values in col H and then paste the values back in col H. Strange.

But how I want it to work is like this:

1. I paste the values into col H44 - H47 (for example)
2. Sum the values from col H44 - H47 into col i44 (=SUM(H44:H47))
and that should kick off the code and populate the row but it doesn't work when I do it that way.
Only if I go through the gymnastics outlined above.
0
SiddharthRoutCommented:
Type the formula first and then paste the values :)

Sid
0
SiddharthRoutCommented:
Unfortunately, I won't be able to amend the code now. I can only do it in the next few days.

I will incorporate the changes for I column.

Sid
0
JaseSAuthor Commented:
opposite way I do it, but yeah, that way works. I guess I can do it that way. I've got to go to bed, and I'll look this over in the morning again. The only problem  I see, is that if I delete the value from i the values in the rest of the row don't delete, which  would be nice. Anyway. Got to go.

Thanks you.
0
JaseSAuthor Commented:
I thought I selected 500 points for this question and that is what I meant it to be. Please change it to give Sid, the solution provider, the points. Thank you.
0
JaseSAuthor Commented:
Thank you Sid. You're saving my skin with each project you do for me. Well done!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.