Using a cell value to determine which column to pul data from

Eric Kelcher

Board Regular
Joined
May 11, 2006
Messages
130
I was hoping there was a way if cell C4 is => a number pull from various columns in Worksheet 2 based on C4 value for all numbers within a range in Worksheet1

Currently i am having to use a lot of if/then statements to make this work correctly and I have just added 2 new payout columns it would be a lot simpler if I could write a code in Worksheet 2 that said if C4>40 use column H if >20 then use column D etc

Worksheet 1
09 Template.xls
ABCDE
420TBK
5JohnKennedyx525
6LyndonBJohnsonx250
7RichardNixonx150
8GeraldFordx125
9JimmyCarterx100
10RonanldReaganx75
11GeorgeBushx75
12BillClintonx75
13GeorgeWBushx75
14BarackObamax75
1511
1612
1713
1814
1915
2035SptBK
21JohnBelushix650
22DanAykroydx325
23JakeBluesx225
24ElwoodBluesx200
25JamesBrownx175
26BBKingx150
27BuddyGuyx150
28RobertJohnsonx150
29MuddyWatersx150
30JohnLeeHookerx150
ASRA

Sample of Worksheet 2 on next post
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
09 Template.xls
BCDEFGHI
2ABCDEFGH
3500525550600650700750800
4225250275300325350375400
5150150175200225250275300
6125125150175200225250275
7100100125150175200225250
875100125150175200225
975100125150175190200
1075100125150175185190
1175100125150175180185
1275100125150175175180
13
14MinfieldMinfieldMinfieldMinfieldMinfieldMinfieldMinfieldMinfield
15016212631364146
CCS-ASRA purse
 
Upvote 0
looks that way doesn't it?


Forgot to mention I need this to run instant, ie a formula that can be into into cell(s) as opposed to a macro.
 
Upvote 0
This is basically what I want to happen, a formula like this in worksheet 2 that worksheet 1 would reference and would then insert the column number referenced in P4 for the forumla in worksheet 1 E5-14 then have a simlar formula in col Q that would work for Worksheet E21-30

This doesn't work and I cannot figure out a way to have the "value" of a column be a variable that I can assign based on a formula

=IF(ASRA!B4>45, P4=column9, IF(ASRA!B4>40, P4=column8, IF(ASRA!B4>35, P4=column7, IF(ASRA!B4>30, P4=column6, IF(ASRA!B4>25, P4=column5, IF(ASRA!B4>20, P4=column4, IF(ASRA!B4>16, P4=column3, column2)))))))
 
Upvote 0
Is there nothing like this VBA code that can be used directly in Excel spreadsheet???

Cells(3, CurCol)

I do have to be able to "grab" the value from another worksheet


So reality it would have to look something like this

Cells(ASRA!3, ASRA!P4)

where ASRA!3 would be my known row number ie fixed and ASRA!P4 would be my variable number for the column determined by the formula in P4.
 
Upvote 0
You could possibley use index

say
ASRA!P3 = 3 (row #)
ASRA!P4 = 10 (column #)

=INDEX(ASRA!A:Z,Row#,Column#)
=INDEX(ASRA!A:Z,ASRA!P3,ASRA!P4)

Would be equivelent of writing
=ASRA!J3

That may get you started.
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,822
Members
449,469
Latest member
Kingwi11y

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