How to Encode Data in Excel (with Easy Steps)

 

Step 1 – Making the Dataset with Proper Parameters

  • You can see our dataset in the image.

Making Data Set with Proper Parameters to Encode Data in Excel


Step 2 – Using the Developer Tab

The Excel built-in Developer tab offers the tools required to use Visual Basic for Applications (VBA) to execute a macro. Typically, the tab is disabled. To make it visible on the toolbar at the top of the Excel window, it has to first be activated in the Options section of the Menu bar.

  • Open the Developer tab.
  • Select the Visual Basic command.

Using Developer Tab to Encode Data in Excel


Step 3 – Creating a VBA User-Defined Function

  • The Visual Basic window will open.
  • From the Insert option, choose Module to write the VBA code.

Creating New Module to Write VBA Code to Encode Data in Excel

  • Paste the following VBA code into the Module.
  • Save the code.
Function Encoding(text$)
Dim i
With CreateObject("ADODB.Stream")
.Open: .Type = 2: .Charset = "utf-8"
.WriteText text: .Position = 0: .Type = 1: i = .Read
With CreateObject("Microsoft.XMLDOM").createElement("b64")
.DataType = "bin.base64": .nodeTypedValue = i
Encoding = Replace(Mid(.text, 5), vbLf, "")
End With
.Close
End With
End Function


Step 4 – Encoding Data in Excel

  • Go to the worksheet and apply the following formula in cell B5.
=Encoding(B5)
  • Hit Enter.

Employing VBA Code to Encode Data in Excel

  • You will see the encoded result for the first person.
  • Use the Fill Handle tool and drag it down from cell B5 cell to cell B11.

  • You will get all the results in the below image.

Read More: How to Check Encoding of Excel File


Download the Practice Workbook


Related Articles


<< Go Back to Excel Encoding | Excel Files | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Bishawajit Chakraborty
Bishawajit Chakraborty

Bishawajit Chakraborty, a Rajshahi University of Engineering & Technology graduate with a B.Sc. in Mechanical Engineering, has been associated with ExcelDemy since 2022. Presently, he is a content developer, specializing in Excel Power Query, Data Analysis and VBA. It is worth mentioning that he has authored more than 90 articles on VBA content development. His profound interest lies in the fields of data analytics and data science. He possesses expertise in VBA, Power BI, machine learning, and Python... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo