I'm having some trouble getting to grips with using/calling variables and other sub routines. I thought I'd use the following bits of code as an example of what I currently have and with your help how you think it SHOULD read.
As you will no doubt guess each Private Sub is attached to a command button, when you click the button it checks to see if the selected cell is within a range and if it is changes it's colour. There are more than 2 buttons in total by the way, I've just using 2 as an example (hence my desire to write tighter code).Please Login or Register to view this content.
The only code difference in the routines is the colour that the cell is changed to, so it would make sense to use variables but I'm falling down at this point as to how to declare them. Also you'll notice the range that the function checks is the same, again a variable for this seems logical called from outside the routine this time?
The way I would expect the whole thing to work is have 1 sub routine written elsewhere that's called when the command button is clicked. The colours would be a variable at the start too. I'm thinking something along the lines of the following (naturally the code is just a concept):
If anyone can spare the time to show me how to improve this code I'd be grateful.Please Login or Register to view this content.
Thanks in advance.
Brelin
Bookmarks