Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Looking up values from range

0

------------------------

Imagine an allowance is given to occupants based on the number of rooms they occupy                           

1. The same occupant can be have 0 or 1 to 4 rooms but will different allowance?                               

2.What formula will I used to extract each room allowance from the table so that each occupant total will equal the total?

3.Please assist to help with the right formula to pull the allowance amount from the table into the rows for each room number?

Answer
Discuss

Discussion

Isaac
 
You need to ask a question to get an answer! The combination of your xlsx file and the mention of User Defined Functions in your original question does not constitute a question to my mind at least- I can't work out what you're trying to achieve.

Please go back to your question and edit it to ask a full question. 
John_Ru (rep: 6152) May 29, '21 at 3:40 pm
Hi John,
I've updated my question, kindly review and revert if you need further clarification. Thanks
siehartley2001 (rep: 14) May 29, '21 at 6:30 pm
Add to Discussion

Answers

0
Selected Answer

Please try this formula.

=VLOOKUP($B3,$G$3:$L$12,$C3+2,FALSE)

Observe that the lookup column is determined by C3 and the range $G$3:$L$12. Since zero rooms is in the second column of the range the formula to calculate the correct column = C3+2.

An error will result if someone enters a number larger than 4 in column C. You might catch that error and display some message. However, in effect, the error message displayed by the system should be desirable in such a case so that no extra accommodation is needed unless you have a maximum. In that case you can embed the above formula in an IFERROR function.

=IFERROR(VLOOKUP($B3,$G$3:$L$12,$C3+2,FALSE),100)

This version of the formula will charge an allowance of 100 if the number of rooms is greater than 4.

Discuss

Discussion

Thanks Variatus for your support.
siehartley2001 (rep: 14) May 30, '21 at 8:39 am
Thanks Variatus for your support.
siehartley2001 (rep: 14) May 30, '21 at 8:39 am
HI Variatis,

Hope you doing well.

is it possible for us to have a team call on  a model am builing?
Thanks
siehartley2001 (rep: 14) Jun 3, '21 at 11:13 am
Hello Sie,
Thank you for selecting my answer. I'm not well set up to work by phone and prefer we stick with the Q & A method supported by this forum, at least for the foreseeable future.
Regards.
Variatus (rep: 4889) Jun 3, '21 at 7:52 pm
Add to Discussion
0

Isaac

If you want to use INDEX/MATCH (as you attempted) then the formula for cell D3 (e.g.) should be:

=INDEX($H$3:$L$12,MATCH(B3,$G$3:$G$12,0),C3+1)
where the column argument of INDEX for the array is C3+1 (so 0 gives 1 for the first column, 1 gives the second etc.). Copy it down and it will work.

Wrap a "catch-all" IFERROR function around it (as Variatus suggests) if you like.

Also, kindly edit your question title- it's very deceptive for other users since it has nothing to do with UDFs. Something like "Looking up values from range" might be more appropriate.

Discuss

Discussion

Thanks John for your support.
siehartley2001 (rep: 14) May 30, '21 at 8:39 am
No problem Isaac. Thanks for your co-operation. 
John_Ru (rep: 6152) May 30, '21 at 9:13 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login