VBA Script
Save this in a text file, reference it as shown in screenshot above.
Function MergeCells(sheetName, startRow, startCol, endRow, endCol) As String
On Error GoTo ErrorHandler
With Sheets(sheetName).Range(Cells(startRow, startCol), Cells(endRow, endCol))
.Merge
.HorizontalAlignment = xlCenter
End With
MergeCells = "Success"
Exit Function
ErrorHandler:
Debug.Print Err.Description
MergeCells = "Error: " & Err.Description
End Function
You may also need to enable this the first time in Excel (if you’ve never done it before).
Open Excel and go into File > Options
Click the Trust Centre tab
Click Trust Centre Settings…
Click the Macro Settings tab
Check the box for Trust access to the VBA project object model