pctechguide.com

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

VBA Macro to See Boy and Girl Names with a Given Letter

Are you looking for a VBA macro that will tell you what names start with a given letter? We came up with one for you!

This macro will prompt you for a letter and then share a list of boy names and a separate list of girl names with that letter. Here is a screenshot of it asking for the letter:

And here is the output after you enter the letter “a”:

The code is listed below. You can obviously add more names to the array. I tried adding the 1,000 most common boy names and 1,000 most common girl names. However, it is a tedious process to add them all at once, because you get an error that there are too many line continuations if you try to copy and paste them in the array at one time. However, if you are ambitious, you can create a very large list with them all.

Sub ShowNamesByLetter()
‘ Define arrays for boy and girl names
Dim boyNames As Variant
Dim girlNames As Variant

boyNames = Array("Aaron", "Abel", "Adam", "Adrian", "Aiden", "Alexander", "Andrew", "Anthony", "Arthur", "Asher", _
                 "Benjamin", "Blake", "Brandon", "Brian", "Bryce", "Caleb", "Cameron", "Carter", "Charles", "Christian", _
                 "Christopher", "Connor", "Daniel", "David", "Dominic", "Dylan", "Elijah", "Elliot", "Ethan", "Evan", _
                 "Gabriel", "Gavin", "George", "Grayson", "Henry", "Hudson", "Hunter", "Isaac", "Isaiah", "Jack", _
                 "Jackson", "Jacob", "James", "Jayden", "John", "Jonathan", "Joseph", "Joshua", "Julian", "Justin", _
                 "Kevin", "Landon", "Liam", "Logan", "Lucas", "Luke", "Mason", "Matthew", "Michael", "Nathan", _
                 "Nathaniel", "Nicholas", "Noah", "Oliver", "Owen", "Patrick", "Paul", "Peter", "Quentin", "Ryan", _
                 "Samuel", "Sebastian", "Thomas", "Tyler", "William", "Wyatt", "Zachary")

girlNames = Array("Abigail", "Addison", "Adeline", "Alexa", "Alice", "Alyssa", "Amelia", "Anna", "Aria", "Ariana", _
                  "Aubrey", "Ava", "Bella", "Brianna", "Brooke", "Camila", "Caroline", "Charlotte", "Chloe", "Claire", _
                  "Clara", "Daisy", "Delilah", "Ella", "Ellie", "Emily", "Emma", "Eva", "Evelyn", "Faith", _
                  "Gabriella", "Grace", "Hannah", "Harper", "Hazel", "Isabella", "Isabelle", "Jasmine", "Julia", "Katherine", _
                  "Kayla", "Layla", "Leah", "Lillian", "Lily", "Lucy", "Madeline", "Madison", "Maya", "Mia", _
                  "Natalie", "Nora", "Olivia", "Penelope", "Peyton", "Quinn", "Riley", "Samantha", "Sarah", "Savannah", _
                  "Scarlett", "Sophia", "Sophie", "Stella", "Taylor", "Victoria", "Violet", "Zoe", "Zoey")

' Prompt user for a letter
Dim inputLetter As String
inputLetter = InputBox("Please enter a letter:", "Enter Letter")

' Check if input is a single letter
If Len(inputLetter) <> 1 Or Not inputLetter Like "[A-Za-z]" Then
    MsgBox "Please enter a single letter.", vbExclamation, "Invalid Input"
    Exit Sub
End If

' Convert input to uppercase for case-insensitive comparison
inputLetter = UCase(inputLetter)

' Find matching names
Dim matchingBoyNames As String
Dim matchingGirlNames As String
matchingBoyNames = ""
matchingGirlNames = ""

Dim name As Variant

For Each name In boyNames
    If Left(UCase(name), 1) = inputLetter Then
        matchingBoyNames = matchingBoyNames & name & vbCrLf
    End If
Next name

For Each name In girlNames
    If Left(UCase(name), 1) = inputLetter Then
        matchingGirlNames = matchingGirlNames & name & vbCrLf
    End If
Next name

' Display results
If matchingBoyNames = "" And matchingGirlNames = "" Then
    MsgBox "No names found starting with the letter " & inputLetter & ".", vbInformation, "No Matches"
Else
    Dim result As String
    result = "Boy Names:" & vbCrLf & matchingBoyNames & vbCrLf & "Girl Names:" & vbCrLf & matchingGirlNames
    MsgBox result, vbInformation, "Names Starting with " & inputLetter
End If

End Sub

We hope you enjoy this macro!

Filed Under: Articles

Latest Articles

Speed Optimization Basics with Windows System Configuration

Slow computers are a bigger concern than we previously thought. One new study found that the average American wastes two hours every week, simply because their computer is running too slow. That means that 1.2% of our lives are being wasted because we aren’t optimizing our PCs to run faster. One … [Read More...]

Top American E-Commerce Stores as of 2017

Typically when we talk about e-commerce, we mean businesses that happen right on the web. In the U.S., e-commerce sales are growing about 10% a year topped by world-famous American sites like Amazon and eBay. Most of the bulk of their sales generally come from mobile gadgets which started to boom in … [Read More...]

Online Gambling Niche — State, Trends, Prospects

In 2021, people continue to stay at home, relaxing with various gadgets, and this is a great opportunity for affiliates to extend their gambling audience. The previous 2020 year has shown good results for the gambling industry. Many countries have simplified the legal framework for gambling, and … [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

5 Pieces of Technology to Boost Your Business in 2021

Let’s face it; running a business is not usually easy. Whether you are self-employed and running your own one-person operation or employing many … [Read More...]

Downsides of Using AI Art Cannot Be Overlooked

AI is changing the way designers and artists create their work. Artificial Intelligence makes it possible to create images faster, more accurately and … [Read More...]

5 Tips to Cure PC Slowness

Today's PCs are designed to be fast and agile. No one wants a computer that takes ages to boot up and even longer to load web pages. This isn't the … [Read More...]

[footer_backtotop]

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