# Keep a Formula Close to its Input

Place a formula close to its input variables. You reduce the chance of mistakes, you make optimal use of Excel’s support, and your spreadsheet becomes easier to carry over to someone else. Essentially, having formulas near their input makes your spreadsheet better. In Guideline no. 4 we talked about separating input and output as much as possible. Guideline no. 3 was about “Calculate formulas only once”. Both rules relate to today’s guideline.

## Optimal Use of the Support in Excel

If you modify a formula in Excel (F2), all the cells used in that formula will be highlighted for your convenience. This is great if you want to see what you are doing, but this only works if all the cells used in your formula are on the same worksheet. Ideally you would place the cells close to the formula itself, this way you will not have to scroll through your workbook to find the cells related to and referenced in your formula. ## Less Chance of Errors

The chance of making mistakes is reduced when the referenced cells and formulas are close to your calculation. This way you can visibly see which values are being referred to, and you can also visibly see the impact of changes that you make. It is also simply easier to follow the logic of a formula when you can see all its parts and there aren’t aspects of it hidden in other worksheets.

## Calculate Everything 1 Time

What does this guideline have to do with “Calculate only once“? Quite simply, if a calculation is close to the variables, change the design to show that certain things belong together. Then, if you need the result of the same formula somewhere else and start recalculating you should quickly be able to see that this has already been done, and does not need to be repeated. This clarity you’ve given yourself will also help your colleagues understand your spreadsheets. ## Input and Output Separated?

You may be wondering, “is this not contrary to strict separation of input, calculations and output?” we have to admit, sometimes that is a bit of a problem. The clever solution is to create a new worksheet and ‘link in’ the source data by using direct references, then you can apply the calculations to the references rather than the original information. If possible, do this, as it also keeps the formulas short. Sometimes a spreadsheet is so big that it is better to leave out these kinds of solutions even though they do add some clarity. In those cases, we would prefer that you place the calculations on a separate tab and not on the same worksheet as your source data. The information in Guideline 4 takes priority over the information in this guideline.

## Incorrect Formula Location

Do you use PerfectXL? If so you may have noticed that PerfectXL does not give a risk message for formula’s far away from the source cells. That would be too strict, we have to draw a line somewhere in what we can do for you. However, PerfectXL does warn against a specific cases related to formulas far from their sources. We call this the ‘Unexpected Formula Location’ and it occurs when, in a long formula, there are considerably more references to a different tab than there are within the tab of the formula. Then there is clearly room for improvement and you should consider moving the formula to a more appropriate location.