The problem
I manage a weighted decision matrix in an Excel file for a team of 15 people. There are 10 columns in the file that contain formulas. The formulas calculate a total weighted score based on the options users select in other cells.
Sometimes a user needs to remove an entry. Common removal methods for my team include selecting an entire row and doing 1 of the following:
- Pressing the delete key.
- Right-clicking and selecting "Clear Contents".
- Selecting "Clear Contents" from the Editing group on the Home tab.
All of these methods also clear the formulas that calculate the weighted scores.
The methods described above are intuitive for most of my team, so I’d like to find a way to let people use these methods without clearing the formulas.
The dream
Allow users to clear everything but the formulas when they use any of the methods described above to clear cells.
Things I've tried
Locking just the formula cells. This prevents users from clearing the formulas, but they can’t clear contents in the other cells when they select the whole row because the formula cells in that row are locked.
The macro below. The macro will clear constants and spare the formulas, but I can't get it to trigger automatically when a "clear contents" event happens. Expecting all the members of my team to run this macro instead of using their regular method for clearing contents is a fool's errand I fear.
Sub ClearOnlyValues() Dim Cel As Range Application.EnableEvents = False Application.Calculation = xlCalculationManual For Each Cel In Selection If InStr(Cel.Formula, "=") = 0 And Cel.Value <> "" Then Cel.ClearContents End If Next Cel Application.EnableEvents = True Application.Calculation = xlCalculationAutomatic End Sub
Google. The only macros I could find all had to be run manually each time you want to clear contents and countless posts demo'ing the Go To Special method of clearing constants. See fool's errand above. If they can't clear cells intuitively, we'll descend into chaos. Cats and dogs living together. It'll be anarchy.
Advanced Excel users who are way smarter than me. They're all stumped.
If you're still with me, thanks for taking the time.