Putting two formulas in one cell

boakley

New Member
Joined
Feb 8, 2018
Messages
36
Hi everyone!

Looking for some help if possible.
I have cell G4 that needs to read data from one of two sheets, depending on the data that is entered for cell D4 (either male or female). The next two cells, E4 (age) and F4 (number of repititions performed) will be manually entered to get the outcome for G4. I just need to know how to put both of these formulas into G4 so that if I input “M” into cell D4, cell G4 will read from the male sheet and vice versa. Thank you in advance for your help!!!

The formulas that I need to put in G4 are:

=IF(D4=“M”(INDEX(MALE_PU!B2:AO117,0),MATCH(MALE_PU!A1:A145,0),MATCH(MALE_PU!B1:AO1,0)))

and the second formula is:

=IF(D4=“F”(INDEX(FEMALE_PU!B2:AO117,0),MATCH(FEMALE_PU!A1:A145,0),MATCH(FEMALE_PU!B1:AO1,0)))
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
General approaches:

1) use an indirect() to conditionally construct the tab reference within the formula
2) use something like choose() or another if() to pick which formula to execute

...but before we get there we need to address the fact that your index() match() constructions aren't working (indexing row 0 won't get you far!)

Can you describe what you're trying to do with these formulas - a worked example would help.
 
Upvote 0
@PaddyD Hi,

Sorry about that. I totally messed that formula up. The correct formula is:

=IF(D4="M",INDEX(MALE_PU!B45:AO117,MATCH(F4,MALE_PU!A45:A117,0),MATCH(E4,MALE_PU!B1:AO1,0)))

The second formula is the same except for the "Male" and "M" would be "Female" and "F" as well as instead of using Sheet 1, it would be using Sheet 2.

I'm not sure why but I am unable to upload the picture of my table that I am building.

I have a few other things that I am trying to do with this as well but my biggest issue is that I cannot seem to figure out how to get both of the formulas into this cell so that it will pull the correct data from the correct place.

So what I am trying to do:
I am a Drill Sergeant and I need to make this table so that we can track how the Privates' Physical Training scores are doing. Each Private has their own row that has their information in it (D4, D5, D6... E4, E5, E6...). Column D is to choose either "Male" or "Female". Column E is to manually input their age. Column F is to manually input the number of repititions performed of the excercise they were doing. I have made different sheets that correspond with the age numbers across the top row and repititions going down the first column. Everything else is the score associated with that age and repititions performed.

The problem is that since male and female physical fitness standards are different, I have to enter their gender into the mix. So essentially, I would like to manually input the gender, which would tell the program which "SHEET" the data is going to come from. Then I would manually input their age and repititions performed so that cell G would populate with their correct score. The formula works but I cannot enter both of them for some reason. I know I am missing something. Also, when I entered the formula into the cell and then hit enter, "FALSE" appeared in the cell. When I entered the gender, the "FALSE" turned to "#N/A". When I entered the age and repititions, the correct score came up like I wanted. I do want to get rid of those errors so that it is blank before starting. I hope this helps. Thank you for your help by the way.

Example of the Table
C
D
E
F
G
1

NAME​

GENDER​

AGE​

PUSH UP REPS​

PUSH UP SCORE​
2

xxxx​

M​

31​

77​

100​
3

xxxx​

F​

31​

50​

100​

<tbody>
</tbody>


Example of Female Score Sheet
B
C
D
E
F
1

AGE​

29​

30​

31​

32​

33​
2

REPS​
3

50​

100​

100​

100​

105​

105​
4

49​

99​

99​

99​

104​

104​
5

48​

98​

98​

98​

103​

103​
6

47​

96​

96​

96​

102​

102​
7

46​

95​

95​

95​

101​

101​

<tbody>
</tbody>



Example of the Male Score Sheet
B
C
D
E
F
1

AGE​

29​

30​

31​

32​

33​
2

REPS​
3

77​

100​

100​

100​

102​

102​
4

76​

99​

99​

99​

101​

101​
5

75​

98​

98​

98​

100​

100​
6

74​

97​

97​

97​

99​

99​
7

73​

96​

96​

96​

98​

98​

<tbody>
</tbody>
 
Upvote 0
Right then...

Given the number of times you're referencing each sheet in each formula I would stay away from option (1) above.

Assuming you've comfortable with the index(match( bits, isn't it just:

=IF(D4="M",INDEX(MALE_PU!B45:AO117,MATCH(F4,MALE_PU!A45:A117,0),MATCH(E4,MALE_PU!B1:AO1,0)),IF(D4="F",INDEX(FEMALE_PU!B45:AO117,MATCH(F4,FEMALE_PU!A45:A117,0),MATCH(E4,FEMALE_PU!B1:AO1,0)),""))

...which basically just wraps your core formulas in a single if()..?
 
Upvote 0
@PaddyD

That worked perfect!!! Thank you so much for that. If it is ok, can I ask you one more thing? I have a conditrional format on the score cells. If the score is >49, the cell turns green and if the score is <50, the cell turns red. If there is no value at all in the score cells, then the score cells stay white. Ever since I input the formulas that you provided, the cell stays green until there is a value that is <50 and only then it turns red. Any idea's? I would like them to stay white until a value is entered.
 
Upvote 0

Forum statistics

Threads
1,215,363
Messages
6,124,505
Members
449,166
Latest member
hokjock

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