Code Protection (Free VBA Obfuscator)

To protect VBA code, you can add a password right from the editor to prevent access to VBA code. Unfortunately this protection is limited and can be bypassed by an aware user.

An effective solution to protect VBA code is obfuscation, in other words, the solution is to make your VBA code "unreadable" (but still operational).

This process is done by removing blank lines and comments and replacing variables, procedures and functions names by random names so that VBA code of your Excel workbook becomes incomprehensible.


Here is an example of a code made unreadable using obfuscation :

BEFORE OBFUSCATION

Sub loops_exercise()

   Const NB_CELLS As Integer = 10 '10x10 checkerboard of cells
   Dim offset_row As Integer, offset_col As Integer ' => adding 2 variables
   
   'Shift (rows) starting from the first cell = the row number of the active cell - 1
   offset_row = ActiveCell.Row - 1
   'Shift (columns) starting from the first cell = the column number of the active cell - 1
   offset_col = ActiveCell.Column - 1
   
   For i = 1 To NB_CELLS 'Row number
   
        For ii = 1 To NB_CELLS 'Column number
       
            If (i + ii) Mod 2 = 0 Then
            'Cells(row number + number of rows to shift, column number + number of columns to shift)
                Cells(i + offset_row, ii + offset_col).Interior.Color = RGB(200, 0, 0) 'Red
            Else
                Cells(i + offset_row, ii + offset_col).Interior.Color = RGB(0, 0, 0) 'Black
            End If
           
        Next
   Next
   
End Sub

AFTER OBFUSCATION

Sub b78a86913923fd45998218c90ae82e3ea()
Const b25f04da8fd373be88988f31960d7700e As Integer = 10
Dim z8752429a9ac65dad58254478ddfa6636 As Integer, w750f1f5c3c111c0af03bc6e6fbabd53c As Integer
z8752429a9ac65dad58254478ddfa6636 = ActiveCell.Row - 1
w750f1f5c3c111c0af03bc6e6fbabd53c = ActiveCell.Column - 1
For z57fbbe9a55b7e76e8772bb12c27d0537 = 1 To b25f04da8fd373be88988f31960d7700e
For m10509d317a03d8e9a09401b6c7d3443f = 1 To b25f04da8fd373be88988f31960d7700e
If (z57fbbe9a55b7e76e8772bb12c27d0537 + m10509d317a03d8e9a09401b6c7d3443f) Mod 2 = 0 Then
Cells(z57fbbe9a55b7e76e8772bb12c27d0537 + z8752429a9ac65dad58254478ddfa6636, m10509d317a03d8e9a09401b6c7d3443f + w750f1f5c3c111c0af03bc6e6fbabd53c).Interior.Color = RGB(200, 0, 0)
Else
Cells(z57fbbe9a55b7e76e8772bb12c27d0537 + z8752429a9ac65dad58254478ddfa6636, m10509d317a03d8e9a09401b6c7d3443f + w750f1f5c3c111c0af03bc6e6fbabd53c).Interior.Color = RGB(0, 0, 0)
End If
Next
Next
End Sub

Obfuscate an Excel VBA code

To easily obfuscate a VBA code, you can use this free tool (important: don’t forget to keep a saved copy of the code or the original file).

Enter your VBA code here:

Enter the list of variables, procedures and functions that you want to replace (tap one name in each line without commas nor special characters):