Check range before pasting and modular approach questions
I am writing some utilities which I plan to bundle together in an add-in for
coworkers. Some of these utilities involve pasting information in
user-selected cells and others involve placing formulas in cells based on
userform input. In either case, I want to check the range prior to
pasting/inserting formulas.
Here is what I am planning to check and how:
- Is the selection a range?
- Is the selection a continuous range (using .Areas)?
- Does the selection contained locked/protected cells (using .AllowEdit)?
- Does the selection contain array formulas (using .HasArray)?
- Does the selection already contain something (using
WorksheetFunction.CountA)?
My questions:
1. Are there additional checks I need to make or any suggestions on the
methods I mentioned?
2. How should I 'arrange' these functions? I could create functions for
each of the checks, then call them from my main subroutine, I could create
one function with all of these checks and call that from my subroutine, or I
could create a function that calls on individual functions and call the one
function from my subroutine. I was planning to use the first option but as
I have just started 'modularizing' my code (versus the fourth option of
putting everything in the subroutine, which is what I used to do) I would
appreciate the opinion of others.
Sorry for the long post. Thanks in advance for your help.
|