This is almost certainly the most unusual question I have ever posted (or ever will post) on this forum.
I have known inputs and (sorta) known outputs and I need Excel formulas (or better still - UDFs) to calculate the outputs.
First picture a user form that we want to place X number of buttons on it (it doesn't matter if you are not familiar with forms - picture cardboard boxes instead). The buttons/boxes are all the same size and will be in alignment with each other. They will be laid out in the shape of a rectangle. I need to calculate 1. the number of rows and 2. the number of columns for any number of buttons/boxes.
Now the tricky bit - there are two goals we need to meet when calculating the number of rows/columns:
- Try to keep the number of boxes on the last row as close as possible to the total no. of columns - in other words, keep gaps to a minumum. I can't have a last row with only one box/button on it.
- Try to keep the rows/column ratio to a visually pleasing ratio (aiming between 1.2 to 1.7. This is not as critical as the previous goal)
It might be easier to work out what I am after by referring to the attached workbook.
So can this be expressed as an Excel formula? If you prefer to calculate this using VBA, a UDF would be great
Bookmarks