assign values to different cell

jeffep

New Member
Joined
Oct 17, 2006
Messages
3
I've got a series of numbers and I'd like to assign a value to a different cell.

A1 14
B1 12
C1 19
D1 27

I'd like to write (somewhere):

if (A1> B1)
E1 = E1 + 3
if (C1 > D1)
E1 = E1 + 4

so I'm constantly changing the value in E1 based on a comparison of numbers in other cells. Is there a way in Excel to do this?

Thanks.

J
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I don't know if you're looking for a formula or VBA solution, but the following VBA procedure should do it.
Code:
Sub Compare_Ranges()

If Range("A1").Value > Range("B1").Value Then
        Range("E1").Value = Range("E1").Value + 3
End If

If Range("C1").Value > Range("D1").Value Then
        Range("E1").Value = Range("E1").Value + 4
End If

End Sub

I'm sure someone else will supply a formula solution.

Mac
 
Upvote 0
Thanks for the quick reply. I'd prefer a formula version, as there will be dozens/hundreds of these comparisons and assignments. But it's nice to know there is a way to do it.
 
Upvote 0
what is the standard value of E1?
if you are inputing data into cell E1 you will not be able to place a formula there.
If the data in E1 is from another cell then it could be done.
Also if bother statements are true would E1 = E1+7?
 
Upvote 0
Put this formula into E1 and it will equal F1

=IF(A1>B1,F1+3+(IF(C1>D1,4,0)),F1+(IF(C1>D1,4,0)))

if A1>B1 it will equal F1 + 3
if C1>D1 it will equal F1 + 4
if A1>B1 and C1>D1 it will equal F1 + 7
 
Upvote 0
I over-simplified in my original question. I've got a series of these numbers

A B C D E F G H
1 12 16 19 24 11 5 34 22
2 11 15 12 22 19 56 33 21
3 19 10 21 44 32 44 13 35
4 33 12 34 19 7 16 34 22
....
32...


What I need is a way to compare and assign values to another cell.

if (a1 > a2)
then a34 = a34 + 3
if (b1 > b2)
then b34 = b34 + 3
...
if (a3 > a4)
then a34 = a34 + 3
...
if (f9 > f10)
then f34 = f34 + 3

Also, I'd like to be able to do:
if (a1 is the highest of a1:h1)
then a34 = a34 + 10
if (b1 is the highest of a1:h1)
then b34 = b34 + 10

Thanks,

J
 
Upvote 0
i think a macro would be best as this could mean a mighty big formula,
it is possible to have a macro that will update your cells when changes are made to the sheet
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,033
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top