VBA – Excel – building a custom formula for C# competition exam

For quite some time I have decided to solve some of the C# competition exams of the SoftUni in Excel. The problem for today is called Cheat Sheet and you may find the description here. Long story short, you have to build a multiplication table (a cheat sheet). The input is the number of column and rows. To make it a little more interesting, the start number of the column and the start number of the row are passed as parameters as well. So, if you have 3 rows, 5 columns, vertical start number 4 and horizontal number 8, the result should be like this:

exampleCheatSheet

To make the things more fun, I have added a fifth boolean parameter, to display the result with tabs or space between the numbers. This is important, becaues when you would like to use the table in Excel, the tabs of the cell do not work as expected and you need spaces there. Pretty much this is how the differences look like:

CheatSheetV1

The one with the tabs between the numbers is obviously more beautiful, but still you need the second option to show it in excel. Last but not least, I made the parameters optional, because it could be useful.

Enjoy the sample:

fCheatSheet

Finally, here comes the code:

Enjoy it! 🙂

Tagged with: , , ,