Determine the type of operating system using VBA in Microsoft Excel

To identify the type of OS, we can use macro code. In this article we will learn how to determine the type of operating system being used using VBA code.

Question: I would like to know the OS of my system through VBA code whether it is 32 bit or 64 bit.

 

To determine the type of operating system we need to follow the below steps:

  • We need to launch VB editor
  • Click on Developer tab
  • From Code group select Visual Basic

image 1

 

  • Click on Insert then Module

image 2

 

  • This will create new module
  • Enter the following code in the Module

 

Function OSis32BIT() As Boolean
    OSis32BIT = False
    If InStr(Application.OperatingSystem, "32-bit") Then
        OSis32BIT = True
    End If
End Function

 

Function OSis64BIT() As Boolean
    OSis64BIT = False
    If InStr(Application.OperatingSystem, "64-bit") Then
        OSis64BIT = True
    End If
End Function

 

Sub TestOSis32BIT()
    If OSis32BIT Then
        MsgBox "You use a 32bit operating system", , _
            Application.OperatingSystem
    Else
        MsgBox "You don't use a 32bit operating system", , _
            Application.OperatingSystem
    End If
End Sub

 

image 3

 

 

As you run the macro you will get a message box, refer to the below snapshot:

 

image 4

 

If you are using 64 bit operating system then the message box will update "You don't use a 32bit operating system"

 

To check whether the system is 32 bit; we can use UDF in an empty cell as:

  • =OSis32BIT(); this will return TRUE if operating system is 32 bit otherwise return FALSE

image 5

 

To check whether the system is 64 bit; we can use UDF in an empty cell as:

  • =OSis64BIT(); this will return TRUE if operating system is 64 bit otherwise return FALSE

image 6

 

Conclusion: In this way using VBA code, we can identify the operating system we are using.

 

image 48

 

If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook.

We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at info@exceltip.com

 
 

Comments

  1. This is not exactly true. It depends on what version of the application is installed. 32-bit Excel installed on a computer running 64-bit Windows 10 returns "Windows (32-bit) NT :.00". So it appears that it returns the version of the application, not the version of the operating system.

Leave a Reply

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

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.