How can I use different columns of data in one column?

ramsayaj

Board Regular
Joined
Jan 15, 2006
Messages
55
Folks,

I have a layout something like this:

A BC D
2 4 6 ?
3 5 2 ?
4 2 3 ?
5 6 4 ?

I would like to be able to enter a reference to either Col A or Col B that would subtract the values in that column from column C and show the result in Col D.

Can anyone help me with how to do this?

Many thanks,
Alan
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi, Alan,

is it this what you mean ?
  A  B  C  D  
1          A  
2 2  4  6  4  
3 3  5  2  -1 
4 4  2  3  -1 
5 5  6  4  -1 

test

[Table-It] version 06 by Erik Van Geit
Code:
RANGE FORMULA (1st cell)
D2:D5 =C2-INDIRECT($D$1&ROW())

[Table-It] version 06 by Erik Van Geit

kind regards,
Erik
 

Harvey

Well-known Member
Joined
Nov 18, 2004
Messages
953
in column E, put the column letter that you want to use (ie. A or B)
in column D, put this formula:
Code:
=C1 - INDIRECT(E1 & ROW(E1))

then drag it down
result will be like this:
A--B--C--D--E
---------------
1--2--5---3--B
9--3--12-3--A
3--4--6---2--B
 

JamieDuncan

Board Regular
Joined
Aug 23, 2006
Messages
132
If the reference is always going to be one or the other an IF statement will do, but you will have to have column E to enter A or B

=IF(E1="A"),SUM(C1-A1),SUM(C1-B1)

If column E = A then it will take A away from C and put result in D you can validate column E to contain only A or B
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
HI,

changed my mind
you could use this
=C2-INDEX(A2:B2,1,$D$1)
(using same sample table as in my previous reply)
I prefer INDEX to INDIRECT

best regards,
Erik
 

Forum statistics

Threads
1,136,271
Messages
5,674,746
Members
419,525
Latest member
helensesc

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
Top