
Share:
Michael Crump works at Vonage on the Developer Experiences team and is a coder, YouTuber, and frequent speaker of various .NET and cloud/communication development topics. He’s passionate about helping developers understand the benefits of each in a no-nonsense way.
Send an SMS Message From an Excel Spreadsheet
Update (June 2026): This post has been refreshed to reflect the current Vonage SMS API endpoint, updated authentication guidance, and security best practices.
Introduction
Microsoft offers a way to add new functionality to Office applications, such as Microsoft Excel, to prompt and interact with the user in ways specific to your business needs. You can perform these tasks more efficiently by using Visual Basic for Applications (VBA). It is a simple but powerful programming language that you can use to do things such as import your contacts from Microsoft Outlook into a Microsoft Excel spreadsheet.
In this blog post, we'll use VBA in Microsoft Excel to send an SMS message. Just enter the cell phone number and the text to send, then press a button to send it! You could modify the code to add additional functionality your business may require, such as scheduling. Let's get started!
Prerequisites
Before we begin, you'll need:
A Vonage API account — once you create one, you'll find your API Key and API Secret on the Vonage API Dashboard under API Settings
A Vonage virtual number to send from — you can purchase one under Numbers > Buy Numbers in the dashboard
Microsoft Excel (any recent version that supports VBA)
Security note: Your API Key and API Secret are sensitive credentials. Never share your spreadsheet with these values filled in, and never commit it to source control. Treat them the same way you would a password.
Vonage SMS API vs. Messages API
Vonage has two APIs for sending SMS: the dedicated SMS API and the multi-channel Messages API. The SMS API is straightforward and a great fit for this use case since we're calling a REST endpoint directly from VBA. If you later want to expand to WhatsApp, MMS, or RCS from the same integration, the Messages API is worth exploring.
For this tutorial, we'll use the SMS API.
Setting Up Your Excel Spreadsheet
As noted earlier, Microsoft Excel can use VBA to interact with data programmatically. Let's begin by creating a spreadsheet with a couple of rows of data, containing the numbers we want to text and the messages we want to send.
Structure your Excel sheet like the following:
A1 & A2 — the cell phone numbers to send to (in E.164 format, e.g., 14255551234)
B1 & B2 — the text messages you want to send
I1 — your Vonage API Key
I2 — your Vonage API Secret
I3 — your Vonage virtual number (the number you purchased in the dashboard, e.g., 18335550100)
I4 — will be the "Send SMS" button (covered shortly)
Give your worksheet a name, such as Numbers.
Tip: Consider protecting cells I1–I3 with a sheet password so credentials aren't accidentally edited or visible to others who open the file.
Now you should have a screen that looks like the following.
ExcelStart.png
Enabling and Configuring Developer Mode in Microsoft Excel
We need to add an option to see the Developer menu option to use VBA. You can turn this on by going to File -> Options -> Customize Ribbon and placing a checkmark in the Developer option, as shown below.
ExcelDevMode.png
The Developer menu option should now appear in the Menu Bar. Select it, then choose Visual Basic to open the code editor.
VisualBasic.png
A new window will appear with Microsoft Visual Basic for Applications running. Select Insert from the menu options and choose Module to input the Visual Basic code that interacts with the Excel sheet.
NewModule.png
Adding the Microsoft XML 6.0 Reference
We need to add a reference to the Microsoft XML 6.0 library, which allows us to call a REST endpoint from VBA. In the Visual Basic editor, go to Tools → References, scroll down to find Microsoft XML, v6.0, check the box, and click OK.
AddReference.png
The VBA Code
Copy and paste the following code block to your application and note the comments that I left that describe what each section is doing.
Sub SendSMS()
' Authentication - read credentials from the spreadsheet
Dim ApiKey As String
Dim ApiSecret As String
Dim FromNumber As String
ApiKey = ActiveSheet.Range("I1").Value
ApiSecret = ActiveSheet.Range("I2").Value
FromNumber = ActiveSheet.Range("I3").Value ' Your Vonage virtual number
' Define our Worksheet so we can loop through the data
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ThisWorkbook
Set ws = wb.Worksheets("Numbers")
' Dynamically determine the last row with data in column A
Dim lastRow As Long
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' Loop through all rows with data
Dim i As Long
For i = 1 To lastRow
Dim toNumber As String
Dim bodyText As String
toNumber = ws.Range("A" & i).Value ' The number to text
bodyText = ws.Range("B" & i).Value ' The message to send
' Use Microsoft's XML Library to make a web request
Dim Request As Object
Set Request = CreateObject("MSXML2.ServerXMLHTTP.6.0")
' Vonage SMS API endpoint
Dim Url As String
Url = "https://rest.nexmo.com/sms/json"
' Open POST request
Request.Open "POST", Url, False
' Set the request header for form-encoded data
Request.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
' Build the POST body with required fields
' Credentials are sent in the POST body, NOT in the URL
Dim PostBody As String
PostBody = "from=" & FromNumber & _
"&to=" & toNumber & _
"&text=" & bodyText & _
"&api_key=" & ApiKey & _
"&api_secret=" & ApiSecret
' Send the request
Request.send PostBody
' OPTIONAL: Show the API response for each message sent
' MsgBox Request.responseText
Next i
MsgBox "Done! " & lastRow & " message(s) sent."
End SubA few things worth calling out in this updated version:
Credentials are sent in the POST body, not appended to the URL. This is the correct and more secure approach — URLs can end up in server logs, browser history, and proxy caches.
The from number is now read from cell I3 rather than being hardcoded. Use your own Vonage virtual number here.
The loop is now dynamic — it uses xlUp to find the last row with data in column A, so you're not limited to two rows. Add as many numbers and messages as you need.
Adding the Send Button
Lastly, we need to add a button to trigger this macro. Select Insert from the Developer menu, click Button, and place it in cell I4.
Once you release your mouse, you'll be asked to Assign Macro to that button. Select the SendSMS macro we just pasted and press OK. Give the button a label like "Send SMS."
ExcelButton.png
Testing It Out
Make sure you have:
A valid phone number in E.164 format in A1 (and A2 if testing two rows), e.g., 14255551234
A message in B1 (and B2)
Your API Key in I1, API Secret in I2, and your Vonage virtual number in I3
Then press the Send SMS button. If everything is configured correctly, you'll see a confirmation dialog and a text message should arrive on the destination phone shortly after.
If you want to inspect the raw API response, uncomment the MsgBox Request.responseText line. A successful response looks like this:
{
"messages": [
{
"to": "14259999999",
"message-id": "3c153507-8ade-4bd1-ab6f-12cb6f7f9efe",
"status": "0",
"remaining-balance": "39.08381985",
"message-price": "0.00869000",
"network": "310260"
}
],
"message-count": "1"
}Note that status: "0" means the message was successfully queued for delivery.
Wrap-Up
In this blog post, we used VBA in Microsoft Excel to send SMS messages via the Vonage SMS API. With just a spreadsheet and a few lines of code, you can send personalized messages to a list of contacts at the click of a button — no dedicated server required.
From here, you could extend this further by:
Adding a timestamp column that logs when each message was sent
Adding error handling to catch failed sends and highlight those rows in red
Exploring the Vonage Messages API if you want to expand to WhatsApp or RCS from the same setup
Have a question or want to share what you're building?
Subscribe to the Developer Newsletter
Follow us on X (formerly Twitter) for updates
Watch tutorials on our YouTube channel
Connect with us on the Vonage Developer page on LinkedIn
Stay connected and keep up with the latest developer news, tips, and events.
Share:
Michael Crump works at Vonage on the Developer Experiences team and is a coder, YouTuber, and frequent speaker of various .NET and cloud/communication development topics. He’s passionate about helping developers understand the benefits of each in a no-nonsense way.