How to Redact all Selected Cells in the Worksheet


In this Excel Training video, we’re addressing a common concern for Excel users when dealing with sensitive data — the need for a swift and efficient way to redact selected cells. We recognize that data privacy and confidentiality are paramount, which is why we’re introducing a practical solution using a straightforward VBA script.

This script simplifies the process, allowing you to quickly and securely redact sensitive information within your Excel worksheet. So join us as we guide you through the script’s implementation, providing you with the tools to safeguard sensitive information while maintaining the integrity of your Excel data.

Resources

Copy and paste the VBA Script:

Sub ConvertToHash()
    Dim selectedRange As Range
    Dim cell As Range
    
    ' Check if a range is selected
    On Error Resume Next
    Set selectedRange = Application.InputBox("Select a range of cells:", Type:=8)
    On Error GoTo 0
    
    ' Exit if no range is selected
    If selectedRange Is Nothing Then
        Exit Sub
    End If
    
    ' Loop through each cell in the selected range
    For Each cell In selectedRange
        ' Convert cell value to #
        cell.Value = String(Len(cell.Value), "#")
    Next cell
End Sub

John Gleave

John Gleave has been a researcher, content writer, and senior editor at Business Tech Planet since 2022. John was formerly a data analyst and web designer with expertise in several programming languages, such as JavaScript, JQuery, PHP, CSS, SQL, and more! With a passion for writing and technology, he has now focused his skills on crafting tech guides for BTP. You can connect with John on LinkedIn.

Recent Posts