How to detect blanks and error values where there should be formulas?

Hello - I have a data entry spreadsheet (Excel 2010) where several users collaborate to enter safety awards data for their corporate divisions. Despite voluminous instructions to the contrary, somebody always wants to copy & paste.

In this particular spreadsheet, half the columns are hidden, because they have formulas that calculate values that are reported in charts & pivot tables. So the copying & pasting stomps on these formulas.

This causes problems with charting , and before each quarter, somebody has to go in and clean up the spreadsheet to make sure everything gets reported.

Is there a VBA routine that can run to detect blanks and #Error values in cells, where the cells above and below contain formulas?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:
You can use something like this in VBA...

To select blank cells in your used range...


Open in new window

And then to select formulas with error...

ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas, 16).Select

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shaun KlineLead Software EngineerCommented:
Just a suggestion: To prevent the issue altogether, why not lock the columns that are hidden and then protect the spreadsheet.
Glenn RayExcel VBA DeveloperCommented:
^This.  As soon as anyone attempts to cut and paste a range that crosses into the protected columns, they'll receive an immediate error.
Shaun KlineLead Software EngineerCommented:
Another suggestion is to move all of the hidden columns to the left, starting at column A. Most users will not notice that there are hidden columns before the first visible column, and therefore they can paste their data in without affecting the hidden columns. Combined with locking the columns, this reduce, if not eliminate the issue you are correcting.
mlagrangeAuthor Commented:
Thanks, Saurabh. (fwiw, I've got this input sheet set up as a data table, with data validation (dependent lists),, and if I lock the  columns, the DV will not come through when the user starts a new row)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.