如何在Excel的IF内置函数中判断工作表是否受保护?
Alright, let's get this sorted! You want to swap out that fixed TRUE/FALSE in your IF function so it reacts to whether the worksheet is protected or not. Here's exactly how to do it:
Key Formula Breakdown
First, we use Excel's CELL function to check the worksheet's protection status. This function returns 1 if the sheet is protected, and 0 if it's not. We can pair this with your original IF logic to match your requirements:
- When the sheet is unprotected (matches your Example 1's
FALSEparameter), return"string" - When the sheet is protected (matches your Example 2's
TRUEparameter), returnNA()
Final Working Formula
=IF(CELL("protect", A1)=1, NA(), "string")
Note: Replace A1 with any cell from the current worksheet — it just needs a reference to the sheet you're checking.
Quick Tip for Auto-Refresh
The CELL function doesn't automatically recalculate unless there's a change in the worksheet. If you need the formula to update instantly when you toggle protection on/off, add a volatile function like NOW() to force recalculation:
=IF(CELL("protect", A1)&NOW()=1&NOW(), NA(), "string")
内容的提问来源于stack exchange,提问作者Sahil Shikalgar

