Checkbox code that works across versions

Copper Contributor

I have a spreadsheet that has a code that calculates based on boxes that are checked. Unfortunately, depending on what version of Excel you have, it doesn't work so I have one coded differently that works for the different version. This causes lot's of issues when sharing with schools across the country because we don't know which version they are using. 

 

My question: Is there a code that I can use to achieve the same calculation that will work with ALL versions of Excel? 

 

Here are the two codes (located in J21 on both):

New version: =J17*IF(D10*G10,0.85,IF(D10*G11,0.8,IF(D11*G10,0.8,IF(D11*G11,0.7,))))

Old Version: 

=IFERROR(_xlfn.IFS(AND(D11=TRUE,G11=TRUE),J17*0.85,AND(D11=TRUE,G12=TRUE),J17*0.8,AND(D12=TRUE,G11=TRUE),J17*0.8,AND(D12=TRUE,G12=TRUE),J17*0.7),J17)

 

I have attached both copies unprotected so you can see what I am trying to calculate. Essentially, it is calculating a tax percentage for taxes based on dependents. 

5 Replies

@britt635 

The IFS function is only available in Excel 2019 and Excel in Microsoft 365, so it won't work in Excel 2016 and earlier versions.

The "New Version" with 3 times IF will work in all versions of Excel. So as long as some of your users have Excel 2016 or earlier, stick with this formula.

Thanks Hans! We use the "New Version" as a default with our program, but quite frequently run into issues where it doesn't work for them in which case we have to end up sending the the "Old Version" for it to work. It just causes a lot of confusion. Do you know why this would be or what we could do to avoid this issue?

@britt635 

 

How open are you to more radical changes in this worksheet?

 

I ask because there are a number of changes that would (I think) make it more robust, and probably easier for the user.

Here are just some examples of things I'd modify and/or question:

  1. The input expected for "Earnings" is a bit ambiguous. Since all the figures below are explicitly monthly, I assumed you wanted monthly earnings as well when I went to try it out. But no, you were expecting annual. And what is "Median" about??  So the clarity of the form right off the bat could use some attention.
  2. In the very formulas you're asking about, you've hard-coded the several tax rates into the formulas. That's generally a "bad practice" because it requires revising the formulas if/when the tax percentages get changed. Far better is to have a table (in a hidden sheet perhaps) that holds those values, makes them visible to you if not to users, and where the values can be changed and from that cascade to any formula that uses them.
  3. I'll grant you that having check boxes for "Married" or "Single", as well as "Child" or "No Child" looks fancy, it forces you to write more complicated formulas (and the posted examples even allowed me to check BOTH entries, which is not good practice either; perhaps that's because it was un-protected)....anyway, given that one is either Married OR Single, a simple "Y/N" or have the question be "Marital Status" with allowed answers "M" and "S" (perhaps also "W" for widowed, "D" for divorced...) all of which could lead (via a table) to simpler formulas than the one you have.

 

There probably would be other things, but those popped out at me.

 

With regard to your question, (if you're not open to the questions I've asked) I would think that a simple IFS function would work with both the old and new forms. The one you posted is different from the one in the actual spreadsheet......

=IFERROR(IFS(AND(D11=TRUE,G11=TRUE),J17*0.85,AND(D11=TRUE,G12=TRUE),J17*0.8,AND(D12=TRUE,G11=TRUE),J17*0.8,AND(D12=TRUE,G12=TRUE),J17*0.7),J17)

 

@mathetes,
Thank you for spending so much time looking at my sheet and providing some great feedback! It's kind of hard to comprehend everything that is going on without context, but the spreadsheet works synonymous with the information they collect with a school program, hence the entry and median salaries. They do research on college and careers and ultimately pick one out to take on a test drive for "real life" while making decisions for housing, transportation, groceries, etc.. It's audience is junior and senior high school students so we are trying to make it look as uncomplicated as possible, while still providing all of the information they need to move onto the next part of the program. I am always open to ideas! I like your second idea and will have to look into that when I have more time. I would say I am a proficient beginner, so these forums (and your feedback) have been really key in my learning.

All that being said, the code you provided at the bottom of your comment is exactly what I am looking for right now, however, when I plug it in on my computer with the newer version of Excel, it doesn't work. :( Any other ideas?
I don't know why that formula wouldn't work on the newer version if it works on the older.

But maybe there's a cell reference or some other easily overlooked nit that throws off the whole thing. What I'd suggest to de-bug it is take each of the sub-conditions (if I can call them that)--each condition that needs to be evaluated--and run them individually in the cells where the whole has to work. My guess is that one or more of them is messing things up.