How to check your operating system using VBA

operating system message box

This VBA code will check your current operating systems and returns the operating system information. You can copy the code and paste it in Excel for Mac or Windows.

Get Access to Your File

Enter your name and email to receive access to the file.

  1. Copy the below VBA Code by clicking on the copy box
  2. Open Microsoft Visual Basic for Applications window Developer Ribbon Tab > Visual Basic (Shortcut keys as follows for mac & windows)
    1. mac users fn + ⌥ [option] + F11
    2. windows users Alt + F11
  3. From the menu bar select Insert > Module and insert new Modules
  4. Paste the code into the module.

Note: It is always good to take a back-up copy of your original before running the code on the original file.

Sub CheckOS()
    'Made It Easy by ExcelExciting.com | Faraz Shaikh | Updated : 20200801
    Dim CheckOS As String
    '******************************************************
  	'Check the Operating system
    CheckOS = Application.OperatingSystem
    MsgBox "You are using " & CheckOS
    '******************************************************
End Sub

So the important part of code in the above code is “Application.OperatingSystem” checks the operating system and return the information.


Was the information helpful in this blog?

  • If yes, hit that share button and show the excitement to the world.
  • Subscribe to our free posts.

Join 2,922 other subscribers

If no, please let us know what to improve.

Having trouble with any Office Apps. Feel free to ask and answer queries at our forums section.


1 1 vote
Article Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Fallon

Thanks. This works great on my Mac. Since I use Mac at work and PC at home, an improvement to your article might be to show a typical result from both environments, that way I could continue to code for both results here at work, without have to port my work to my home computer to see what results I will get there. It would save me a day’s worth of time.

1
0
Would love your thoughts, please comment.x
()
x