Create right code and find output based on table

thocam

New Member
Joined
May 7, 2011
Messages
26
Hi everybody

I am having problems making the right VBA code (It must be written in VBA)

This is my setup:
I have to fill in three dimensions (they can range from 20 to 220) and then, by using code and the underlying table, excel needs to give the corresponding price.


<TABLE style="WIDTH: 240pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=320><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; WIDTH: 48pt; HEIGHT: 15pt; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" height=20 width=64 align=right>20</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; WIDTH: 48pt; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" width=64 align=right>30</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; WIDTH: 48pt; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" width=64 align=right>40</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; WIDTH: 48pt; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" width=64></TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; WIDTH: 48pt; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" width=64>$3</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; HEIGHT: 15pt; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" height=20 align=right>50</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" align=right>60</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" align=right>80</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0"></TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0">$0</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; HEIGHT: 15pt; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" height=20 align=right>50</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" align=right>100</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" align=right>180</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0"></TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0">$3</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; HEIGHT: 15pt; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" height=20 align=right>100</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" align=right>200</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0" align=right>220</TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0"></TD><TD style="BORDER-BOTTOM-COLOR: #f0f0f0; BACKGROUND-COLOR: transparent; BORDER-TOP-COLOR: #f0f0f0; BORDER-RIGHT-COLOR: #f0f0f0; BORDER-LEFT-COLOR: #f0f0f0">$12</TD></TR></TBODY></TABLE>


But here is the catch, if one of the three values exceeds than it has to take the next price. So for example:
If I fill:
22 30 40 then this has to give 0
20 35 42 = 3
51 60 70=3
51 100 180 = 12

How can I do this? Thank you very much all.
<!-- / message -->
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,224,517
Messages
6,179,242
Members
452,898
Latest member
Capolavoro009

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