VBA If Else Help

DalPai

New Member
Joined
Aug 13, 2018
Messages
29
Hello everyone!


I have a "problem" in a spreadsheet that I believe through VBA I could solve. But I never programmed in VBA, so I have no idea where to start.

I have a table with the following information: Project Name, Type, Stage, Value, Adjusted Value.

The adjusted value depends on the stage the project is.
ex: If a project of value 100 is in the Idea stage, its adjusted value is 100*10% = 10

I was able to solve this simply by using =IF in excel.

However, the percentage will also change according to the Project type. And writing such a formula using =IF would be huge.


I believe that by VBA I can do this easily, but where to start?

Best Regards
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
How many project types are there?
 
Upvote 0
You may be able to accomplish what you want without VBA. You can set up a lookup table that has your various Projects and Stages and associated value, and then you can use an Index/Match formula to look up the appropriate value from that table.
See here: https://spreadsheeto.com/index-match/
 
Upvote 0
Hi Fluff,

There are 7 types, but the % changes only with one Type.

Type: Core
Stage 0: 0%
Stage 1: 15%
Stage 2: 25%
Stage 3: 40%
Stage 4: 50%
Stage 5: 100%

Type: Other 6
Stage 0: 0%
Stage 1: 5%
Stage 2: 20%
Stage 3: 40%
Stage 4: 90%
Stage 5: 100%
 
Upvote 0
Ok, how about


Book1
ABCDE
1Project NameTypeStageValueAdjusted Value
2CoreStage 01000
3CoreStage 110015
4CoreStage 210025
5CoreStage 310040
6CoreStage 410050
7CoreStage 5100100
8??Stage 01000
9??Stage 11005
10??Stage 210020
11??Stage 310040
12??Stage 410090
13??Stage 5100100
RC
Cell Formulas
RangeFormula
E2=D2*IF(B2="Core",CHOOSE(RIGHT(C2,1)+1,0,0.15,0.25,0.4,0.5,1),CHOOSE(RIGHT(C2,1)+1,0,0.05,0.2,0.4,0.9,1))
 
Upvote 0
You may be able to accomplish what you want without VBA. You can set up a lookup table that has your various Projects and Stages and associated value, and then you can use an Index/Match formula to look up the appropriate value from that table.
See here: https://spreadsheeto.com/index-match/

I completely forgot about the INDEX/MATCH formula.

Worked like a charm. Thank you very much
 
Upvote 0
You are welcome.
Glad we were able to help.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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