Skip to main content

Three methods quickly hide/mask cell contents with asterisk or other string in Excel

Author: Sun Last Modified: 2024-10-28

Sometimes, you may want to hide some cell contents while you sharing the workbook to other users as below screenshot shown. Here, this article will introduce three methods on masking cells with asterisk for hiding the contents in Excel.
mask cell contents with asterisk


Hide and mask cell contents with asterisk with Format Cells

In Excel, to mask cell contents with asterisk, you can use the Format Cells function.

1. Select the cells you want to hide with asterisk, then right click to select Format Cells from the context menu.
Select the cells, right click to select Format Cells

2. In the Format Cells dialog, under Number tab, select Custom from Category list, and then type ;;;** into the textbox under Type.
specify the formatting in the dialog box

3. Click OK, now the select cell contents have been masked with asterisks.
the select cell contents have been masked with asterisks

But the cell contents also can be viewed in the formula bar.
the cell contents also can be viewed in the formula bar

4. Place cursor at the cell you do not want to hide contents, then click Review > Protect Sheet, and uncheck Select unlock cells and Format cells option (other options you can check as you need), then type and confirm the password for protecting the sheet in the popping dialogs.
uncheck Select unlock cells and Format cells option in the Protect Sheet and type and confirm  the password

Then the cell contents have been hidden and masked with asterisks.

Note: If the cell contents are numeric string, this way only with display the cell contents as blank.
if the cell contents are numeric string, the cells are displayed  as blank


Hide rows with #N/A or other specific error values by VBA code

If you want to mask both numbers and texts, you can apply VBA code.

1. Select the cells you want to encrypt, and press Alt + F11 keys to enable Microsoft Visual Basic for Applications window.

2. Click Insert > Module, then copy and paste below code to the new Module.

VBA: Hide #N/A error rows

Sub E_Cells()
'UpdatebyExtendoffice
Dim xRg As Range
Dim xERg As Range
Dim xWs As Worksheet
Dim xStrRg As String
Dim xStrPw As String
xStrPw = ""
xStrPw = Application.InputBox("Enter Password", "", "", Type:=2)
If xStrPw = "" Then Exit Sub
On Error Resume Next
Set xERg = Selection
Set xWs = Application.ActiveSheet
Set xRg = xWs.Cells
xRg.Locked = False
xERg.Locked = True
xERg.NumberFormatLocal = "**;**;**;**"
xWs.Protect Password:=xStrPw, DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub 

3. Press F5 key to run the code. And then type password in the popping out dialog, and click the OK button. See screenshot:
vba code to enter a password

Tip:

1. For decrypting the cells, you can use below macro code.

Sub D_Cells()
'UpdatebyExtendoffice
Dim xRg As Range
Dim xERg As Range
Dim xWs As Worksheet
Dim xStrRg As String
Dim xStrPw As String
xStrPw = ""
xStrPw = Application.InputBox("Type Password", "", "", Type:=2)
If xStrPw = "" Then Exit Sub
On Error Resume Next
Set xWs = Application.ActiveSheet
Set xRg = xWs.UsedRange
xERg.NumberFormatLocal = "**;**;**;**"
xWs.Unprotect Password:=xStrPw
For Each xERg In xRg
    If xERg.Locked Then xERg.NumberFormatLocal = "@"
Next
End Sub

2. With the VBA code, the cell contents also can be viewed in formula bar.


Encrypt and mask cell contents with asterisk or other string

If you want to encrypt and mask cell contents with the special string as you need, the Encrypt Cells feature of Kutools for Excel can do a nice favor.

The Encrypt Cells tool in Kutools for Excel can:

1. Encrypt cells with blank
2. Encrypt cells with characters
3. Encrypt cells with a specified string.

Kutools for Excel contains 300 advanced tools for solving your 90% Excel puzzles, and provides you a 30-day free trial.

After free installing Kutools for Excel (30-day free trial), please do as below steps.

1. Select the cells you want to mask, then click Kutools Plus > Encrypt Cells.
doc mask cell 9

2. Then in the popping dialog, type and confirm the password, then in Mask section, check the option as you need.
type and confirm the password, check the option

3. Then click Ok. At present, all selected cells have been masked.

Check None, the cells display a string of gibberish.
Check None
doc mask cell 12

Check Char option, you can type any character into the textbox, then the cells will display the character only.
Check Char option
the cells will display the character only

Check String option, then type the string you want the cells display.
Check String option
cells are displayed with strings

Tip: if you want to decrypt the cells or display the cell contents, you can click Kutools Plus > Decrypt Cells, then type the password to successfully decrypt.
click Kutools Plus > Decrypt Cells to decrypt the cells


Other Operations (Articles) Related To Hidding

Hide rows based on value
This tutorial provides some methods on hiding rows based on the value (equal to/greater than/less than) in another column in Excel.

Hide part of text string
Sometimes, you want to hide part of string to protect the private information, such as phone number 123-xxx-xxxx, how can you do? In this article, you will find the easy solutions.

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!