Tuesday 20 November 2012

Pushing my VBA skills

While working at Three I have continued to push my (limited) VBA skills.  Today I have successfully managed to setup some code to password protect an entire spreadsheet at the push of a button and unprotect it with another.

I've also managed to get a number of charts to automatically adjust the y-axis values based on a cell value.  The reason for this is that when charting something that has a constant range between 99 and 100% you'll barely notice the differences if the scale starts at 0, as it would if using the standard Excel settings.  If you set the minimum scale value to 98% then you'll be able to see the trend in more useful detail.  However, if you get a value less than 98%, then you'll not see it on the chart.  Unless you set up some code that will change the minimum axis value to equal the minimum chart value :)

Now the trouble with this in a password protected workbook is that the charts won't update, the axis will remain fixed.  So I had to add code to the sheet with the charts to unprotect the sheet before adjusting the scale, and then protect the sheet again at the end.  It's all quite easy once you get the hang of it.  Coding is very modular; you can copy chunks from one part to another and increase the functionality of the Dashboard immeasurably.

When I get chance I'll upload some videos of it in practice and show you the magician behind the curtain.  Until then, you'll have to take my word for it :D

No comments:

Post a Comment