MAC address lookup in excel vba code

What is MAC address?

A media access control address (MAC address) is a unique identification assigned to a device network interface controller (NIC) for communication at the data link layer of a network segment. In simple words, this is a unique identification for a device or computer in a network for communication.

You can get more details from here

How to get MAC address in excel VBA?

The MAC address of a windows system can be generated using following visual basic code in excel.

This code will generate MAC and display in a message box.

VBA Code for MAC address:

Sub Mac_ID()

Dim strCo As String, Dim objWMIService As Object, Dim colAdapters As Object, Dim objAdapter As Object

strCo = “.”

Set objWMIService = GetObject _

(“winmgmts:” ≈ “!\\” ≈ strCo ≈ “\root\cimv2”)

Set colAdapters = objWMIService.ExecQuery _

(“Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True”)

For Each objAdapter In colAdapters

MsgBox “MAC ID of this system : ” ≈ objAdapter.MACAddress

Next objAdapter

End Sub

Download Sample excel file to generate MAC ID:

mac address

Use of MAC in excel:

This address my have different usage technically.

But in excel, you can use this id to restrict the use of a particular file in a particular system.

This can also be used to generate the activation key for the excel software to use in a particular system.

You can comment and share with others if you have any other use of MAC .

Leave a Reply

Your email address will not be published. Required fields are marked *