pctechguide.com

  • Home
  • Guides
  • Tutorials
  • Articles
  • Reviews
  • Glossary
  • Contact

VBA Macro to See If Your Birthday is the Same As a US President

This is an election year, so people are showing a lot of interest in politics right now. We thought it would be cool to create a VBA macro that makes an otherwise frustrating and stressful election season a little more fun.

This macro will ask for your birthday and then tell you if you share the same birthday as a United States president.

Here is a screenshot of the macro asking for your birthday:

ask for input presidential VBA maco

And here is the output:

VBA MAcro presidential output 2

Sub CheckPresidentialBirthday()
‘ List of U.S. presidents’ birthdays (MMDD format)
Dim presidentsBirthdays As Collection
Set presidentsBirthdays = New Collection

‘ Adding all presidents’ birthdays
presidentsBirthdays.Add “0222”, “George Washington” ‘ George Washington
presidentsBirthdays.Add “1030”, “John Adams” ‘ John Adams
presidentsBirthdays.Add “0413”, “Thomas Jefferson” ‘ Thomas Jefferson
presidentsBirthdays.Add “0711”, “James Madison” ‘ James Madison
presidentsBirthdays.Add “0428”, “James Monroe” ‘ James Monroe
presidentsBirthdays.Add “0711”, “John Quincy Adams” ‘ John Quincy Adams
presidentsBirthdays.Add “0315”, “Andrew Jackson” ‘ Andrew Jackson
presidentsBirthdays.Add “1205”, “Martin Van Buren” ‘ Martin Van Buren
presidentsBirthdays.Add “0318”, “Grover Cleveland” ‘ Grover Cleveland
presidentsBirthdays.Add “1004”, “Rutherford B. Hayes” ‘ Rutherford B. Hayes
presidentsBirthdays.Add “1102”, “James K. Polk” ‘ James K. Polk
presidentsBirthdays.Add “0810”, “Herbert Hoover” ‘ Herbert Hoover
presidentsBirthdays.Add “0820”, “Benjamin Harrison” ‘ Benjamin Harrison
presidentsBirthdays.Add “0304”, “William McKinley” ‘ William McKinley
presidentsBirthdays.Add “0915”, “William Howard Taft” ‘ William Howard Taft
presidentsBirthdays.Add “1027”, “Theodore Roosevelt” ‘ Theodore Roosevelt
presidentsBirthdays.Add “0808”, “Richard Nixon” ‘ Richard Nixon
presidentsBirthdays.Add “0714”, “Gerald Ford” ‘ Gerald Ford
presidentsBirthdays.Add “1001”, “Jimmy Carter” ‘ Jimmy Carter
presidentsBirthdays.Add “0614”, “Donald Trump” ‘ Donald Trump
presidentsBirthdays.Add “1120”, “Joe Biden” ‘ Joe Biden

‘ Prompt user for their birthday
Dim userBirthday As String
userBirthday = InputBox(“Please enter your birthday (MM/DD/YYYY):”, “Enter Birthday”)

‘ Ensure valid date input
On Error Resume Next
Dim userDate As Date
userDate = DateValue(userBirthday)
On Error GoTo 0

If userDate = 0 Then
MsgBox “Invalid date format. Please enter the date in MM/DD/YYYY format.”, vbExclamation, “Invalid Date”
Exit Sub
End If

‘ Extract MMDD part from the input
Dim monthDay As String
monthDay = Format(userDate, “MMDD”)

‘ Check if the entered MMDD matches any president’s birthday
Dim presidentName As String
Dim matchFound As Boolean
matchFound = False

On Error Resume Next
presidentName = presidentsBirthdays(monthDay)
On Error GoTo 0

If presidentName <> “” Then
matchFound = True
End If

‘ Display result to the user
If matchFound Then
MsgBox “You share your birthday with President ” & presidentName & “!”, vbInformation, “Birthday Match”
Else
MsgBox “You do not share your birthday with any U.S. president in the list.”, vbInformation, “No Match”
End If
End Sub

We hope you enjoy using this macro!

Filed Under: Articles

Latest Articles

IEEE 802.11b

The 802.11b group within IEEE was driven largely by Lucent Technologies and Intersil Corp., and was designed to operate in the 2.4GHz ISM (Industrial, Scientific and Medical) band. The key contribution of the 802.11b addition to the … [Read More...]

11 alternatives to Movie Maker for editing videos in Windows 10

We bring you a short list with the top 11 alternatives to Movie Maker so you can edit your videos in Windows 10. Even today, we all remember with nostalgia the mythical Movie Maker, a simple editor that you can still install on Windows 10, although it has been years since it stopped receiving … [Read More...]

4 Experts Share Insights on the Intersection of Tech Support & Business Growth

There is certainly no shortage of technology that businesses can leverage to grow and be more successful than competitors. The innovative tech streamlining a number of daily, monthly, and even quarterly business processes continues to enter the market in every industry. “Whether you're part of a … [Read More...]

Gaming Laptop Security Guide: Protecting Your High-End Hardware Investment in 2025

Since Jacob took over PC Tech Guide, we’ve looked at how tech intersects with personal well-being and digital safety. Gaming laptops are now … [Read More...]

20 Cool Creative Commons Photographs About the Future of AI

AI technology is starting to have a huge impact on our lives. The market value for AI is estimated to have been worth $279.22 billion in 2024 and it … [Read More...]

13 Impressive Stats on the Future of AI

AI technology is starting to become much more important in our everyday lives. Many businesses are using it as well. While he has created a lot of … [Read More...]

Graphic Designers on Reddit Share their Views of AI

There are clearly a lot of positive things about AI. However, it is not a good thing for everyone. One of the things that many people are worried … [Read More...]

Redditors Talk About the Impact of AI on Freelance Writers

AI technology has had a huge impact on our lives. A 2023 survey by Pew Research found that 56% of people use AI at least once a day or once a week. … [Read More...]

11 Most Popular Books on Perl Programming

Perl is not the most popular programming language. It has only one million users, compared to 12 million that use Python. However, it has a lot of … [Read More...]

Guides

  • Computer Communications
  • Mobile Computing
  • PC Components
  • PC Data Storage
  • PC Input-Output
  • PC Multimedia
  • Processors (CPUs)

Recent Posts

Safely Overwrite the Deleted Files: Cipher and Eraser

When someone deletes files on their PC, Windows users knew it wasn't really gone and it can be recovered. The deleted files are still there on your … [Read More...]

How Often Should You Shut Down Your Computer?

Many people wonder if they should shut down their computer each day or leave it on. Furthermore, they wonder how often they should shut down their … [Read More...]

ISDN

ISDN (Integrated Services Digital Network) has been regarded by many as the best kept secret of the computer networking world for too long. The … [Read More...]

[footer_backtotop]

Copyright © 2025 About | Privacy | Contact Information | Wrtie For Us | Disclaimer | Copyright License | Authors