Hi All
This may or may not be a long shot, but I'll ask anyway!
I have a complex workbook that is regularly sent to clients for them to enter data and return. There is a lot of simple validation in place, and there is also a 'Confirm' button at the top of each sheet with code behind it that runs a lot of more complex validation for certain columns (using values in other cells, etc.). The 'Confirm' button ultimately generates 1 of 3 possible outcomes:
If 'There are warnings', a comment is added to the cell, a Warnings flag is set to True, a Warnings count goes up by 1, and the cell fillcolour is set to yellow. This is done by (for example):
- The data is fine
- There are warnings
- There are errors
There is a similar routine if 'There are errors'.![]()
Please Login or Register to view this content.
This all works perfectly well
The issue is that the above code is repeated for different columns many times over, for different warnings/errors, so it seems to me that instead of repeating the whole warnings/errors process I should be able to write a simple Sub that would take as parameters the cell address and the warning/error comment, and would then do the business. So the Sub would be something likeand for the above example the call to the Sub would be something like:![]()
Please Login or Register to view this content.
. . . which would need to have the same effect as the code in lines 1390 to 1450 above.![]()
Please Login or Register to view this content.
The new Sub FailData works as far as adding the comment and fillcolour to the relevant cell on the sheet, but the assignments to WarningsThisPass / intWarningsCount / ErrorsThisPass are not happening. I'm guessing that this is something to do with those variables not being available from the Sub FailData, but I cannot see how to overcome this.
I hope someone has read all this, and can help me out
Very many thanks in advance
Les
Bookmarks