VBA & Macro Problems

Fix Excel VBA WhatsApp Messages Sending Only to the First Number

Maira MehtabMaira Mehtab Dec 2, 2026 868 views

Question details

The user needs an Excel VBA routine to process a list of phone numbers and WhatsApp messages rather than stopping after the first entry.

Fix Excel VBA WhatsApp Messages Sending Only to the First Number
Product
Microsoft Excel VBA and WhatsApp
Device & OS
not provided
Scenario
An Excel worksheet contains multiple recipients and messages to open in WhatsApp.
Observed behavior
The automation sends only the first message to the first phone number.
Before you start

Put phone numbers in column A and messages in column B, starting on row 2. Store numbers as text using the international format with country code and digits only, and sign in to WhatsApp Web or your WhatsApp desktop app.

Solution 1Recommended

Loop Through Excel Rows and Confirm Each WhatsApp Send

Use this approach to open a separate WhatsApp chat for each valid row and prevent the loop from racing ahead before you send the message.

The example opens a prefilled WhatsApp chat; it does not press Send automatically. Send each message yourself, then return to Excel and confirm before the macro opens the next chat.

The example uses ENCODEURL in Windows desktop Excel. Very long messages can exceed link or browser limits; shorten or split them, or consider an authorized WhatsApp Business Platform integration.

1
Open the VBA editor

In Excel, open the worksheet with your list, press Alt+F11, and select Insert > Module. Enable macros only if you trust the workbook and its code.

2
Add the row-processing macro

Paste the following code into the module: Sub OpenWhatsAppMessages() Dim ws As Worksheet Dim lastRow As Long, r As Long Dim phone As String, msg As String, link As String Set ws = ActiveSheet lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row For r = 2 To lastRow On Error GoTo RowError phone = Trim$(CStr(ws.Cells(r, "A").Value2)) msg = CStr(ws.Cells(r, "B").Value2) If Len(phone) = 0 Or phone Like "*[!0-9]*" Or Len(Trim$(msg)) = 0 Then MsgBox "Check the number and message on row " & r & ".", vbExclamation GoTo NextRow End If link = "https://wa.me/" & phone & "?text=" & Application.WorksheetFunction.EncodeURL(msg) ThisWorkbook.FollowHyperlink Address:=link If MsgBox("Send the message for row " & r & " in WhatsApp, then click OK to continue. Click Cancel to stop.", vbOKCancel + vbInformation) = vbCancel Then Exit Sub GoTo NextRow RowError: MsgBox "Could not open row " & r & ": " & Err.Description, vbExclamation Resume NextRow NextRow: On Error GoTo 0 Next r End Sub

3
Run and verify each message

Return to the worksheet, select Developer > Macros, choose OpenWhatsAppMessages, and click Run. Wait for each chat to load, check the recipient and message, click Send in WhatsApp, and then click OK in Excel to continue.

4
Review skipped rows

If Excel reports an invalid row or an error, check columns A and B for missing values, non-digit characters in the number, or a message that is too long. Correct the row before running the macro again.

Loop Through Excel Rows and Confirm Each WhatsApp Send
Avoid duplicate sends: The example does not record which rows were sent. If you rerun it, remove or otherwise exclude completed rows to avoid sending the same message again.
Free Microsoft Office alternative

Manage Your Message List in WPS Spreadsheet

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open compatible Excel files and organize recipient lists in WPS Spreadsheet; Excel VBA automation may require separate compatibility checks and is not repaired by switching apps.

Organize phone numbers and message text in spreadsheet columns.Open and edit compatible Microsoft Excel XLSX and XLS files.Move familiar spreadsheet workflows into an easy-to-use interface.Use a lightweight office suite with free core tools.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my macro stop after the first WhatsApp message?

The send or link-opening action may be outside the row loop, the loop may be exiting early, or an error may stop execution. In the VBA editor, check the For loop and error handling, then step through the code with F8.

Does a wa.me link send the message automatically?

No. A wa.me link opens a chat with the encoded text prefilled. Wait for WhatsApp to load, review the recipient and message, and click Send yourself.

How should I enter phone numbers in Excel?

Format column A as Text before entering numbers. Include the country code and use digits only, without a plus sign, spaces, or punctuation.

Why won't a very long message open in WhatsApp?

The encoded message may make the URL longer than Excel, the browser, or the receiving app can handle. Try shortening or splitting the message, or use an authorized WhatsApp Business Platform integration.

Will rerunning the example send messages only to unfinished rows?

No. The example starts at row 2 every time and does not track completed sends. Remove or exclude completed rows before running it again.