Help with a formula

New Contributor

Hi all, I am pretty much a beginner to excel and formulas, so I was wondering if anyone out here knew about a formula that would work for me, or if its not a possibility at all.


What I am hoping to accomplish is to be able to type in either a "y" or a "n" into a cell, and then have that cell produce a number. The number I would like it to produce is predicated by the cell above it.


For example, if the cell in B2 has a "5S" in it, and I type a "y" into cell B3, I would like for cell B3 to return a number like "5T", where-as if I type in a "n" into cell B3, I would like for B3 to return a number such as "4v".


I have a limited knowledge of excel, in that I know I could input all the values I would like for it to return on another sheet if need be, but I am unsure of whether or not that would be helpful/necessary.


Any advice or help on this would be greatly appreciated.

Thank you!

7 Replies


It would be better to use a different cell for the result: if you enter specific values in B2 and B3, a formula can return the resulting value in - for example - B4.


Could you provide some details about which values can be entered in B2 and B3?

Ok, so my friends and I play some tabletop games, for which we have various dice that we use for different things.

The values I would like to be shown are things like "2d12+1d6".

The Dice will go up or down if the players succeed or fail at something.

For example if person a succeeds at a task, and they are currently at "2d12+1d6", I would like for the number for them to increase to "2d12+1d8", whereas if they failed, the number would decrease to "2d12+1d4".

So I would like to be able to just enter a "y" or "n" to say whether or not they succeeded, and then have the result go either up one die size, or down one die size accordingly.

Hopefully that's understandable enough.

Thank you.


Sounds complicated. Do you have a list of possible values?

So the list would be:
0, 1d4, 1d6, 1d8, 1d10, 1d12, 1d12+1d4, 1d12+1d6, 1d12+1d8, 1d12+1d10, 2d12, 2d12+1d4, 2d12+1d6, 2d12+1d8, 2d12+1d10, 3d12, 3d12+1d4, 3d12+1d6, 3d12+1d8, 3d12+1d10, 4d12.

That would be the whole range.

Thanks again!



See the attached sample workbook. It is a macro-enabled workbook so you'll have to allow macros when you open it.

To inspect the VBA code, right-click the sheet tab and select 'View Code' from the context menu. I have added comments to the code; this should help if you want to modify it.

@Hans Vogelaar 

Ok, sorry for the delay, work got busy and I forgot to check back on here.


I see the pull down with the options next to it on the excel file, but if I select either "y" or "n", nothing changes.

Not sure what I am doing wrong, any thoughts?


Make sure that you open the workbook in Excel for Windows or MacOS. VBA doesn't work in Excel for Android or iOS, nor in the browser version.

And make sure that you allow macros when you open the workbook.