How to Add Single Quotes and Comma in Excel Formula (4 Ways)

Here’s an overview of the dataset, where we’ll concatenate the values from the first two columns and add quotes and a comma.

add single quotes and comma in excel formula


Method 1 – Use the CHAR Function to Add Single Quotes and Comma

Steps

  • Select cell D5.

Use CHAR Function to Add Single Quotes and Comma

  • Use the following CHAR function in the selected cell:
=CHAR(39) & B5 & CHAR(39) & CHAR(44) & CHAR(39) & C5 & CHAR(39)

CHAR(39) return a single quote and CHAR(44) returns a comma.

  • Press Enter on your keyboard.

Use CHAR Function to Add Single Quotes and Comma

  • AutoFill the CHAR function to the rest of the cells in column D.

Read More: How to Concatenate Single Quotes in Excel


Method 2 – Merge CONCATENATE and CHAR Functions to Add Single Quotes and Comma

Steps:

  • Select cell D5.
  • Insert the following function:
=CONCATENATE(CHAR(39), B5, CHAR(39), CHAR(44), CHAR(39), C5, CHAR(39))

Formula Breakdown:

  • Inside the CONCATENATE function, CHAR(39) returns a single quote and CHAR(44) returns a comma.
  • The CONCATENATE function concatenates all the strings inside of it.

Merge CONCATENATE and CHAR Functions to Add Single Quotes and Comma

  • Hit Enter to get the first result.

  • AutoFill the formula throughout column D.

Merge CONCATENATE and CHAR Functions to Add Single Quotes and Comma

Read More: How to Add Single Quotes in Excel for Numbers


Method 3 – Apply Ampersand to Add Single Quotes and Comma in Excel Formula

Steps:

  • Select cell D5.
  • Use the following formula inside it:
="'"&B5&"'"& "," &"'"&C5&"'"

Apply Ampersand to Add Single Quotes and Comma in Excel Formula

  • Press Enter to get the first result.

  • AutoFill the formula to the rest of the cells in column D.

Apply Ampersand to Add Single Quotes and Comma in Excel Formula


Method 4 – Create a User-Defined Function Using Excel VBA Code to Add Single Quotes and Comma

We have a modified dataset where we’ll concatenate the entire column in a single cell.

Steps:

  • In the Developer tab, select Visual Basic.

Create User Defined Function Using Excel VBA Code to Add Single Quotes and Comma

  • A window named Microsoft Visual Basic for Applications will appear.
  • Go to Insert and choose Module.

  • Insert the following code in the Module.
Function ColumntoList(ColRange As Range)
    Dim ListOutput
    Dim cell As Variant
    For Each cell In ColRange
        If Not IsEmpty(cell.Value) Then
            ListOutput = ListOutput & "'" & cell.Value & "',"
        End If
    Next
     ColumntoList = Left(ListOutput, Len(ListOutput) - 1)
End Function

Create User Defined Function Using Excel VBA Code to Add Single Quotes and Comma

  • Go to Run and select Run Sub or press F5.

  • Go back to the worksheet.
  • Use the following code in cell C5.
=ColumntoList(B5:B10)

Create User Defined Function Using Excel VBA Code to Add Single Quotes and Comma

  • Press Enter.

Create User Defined Function Using Excel VBA Code to Add Single Quotes and Comma


Things to Remember

#N/A! error arises when the formula or a function in the formula fails to find the referenced data.

#DIV/0! error happens when a value is divided by zero(0) or the cell reference is blank.


Download the Practice Workbook


Related Articles


<< Go Back to Quotes in Excel | Concatenate Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Abdur Rahim Rasel
Md. Abdur Rahim Rasel

MD. ABDUR RAHIM is a marine engineer proficient in Excel and passionate about programming with VBA. He views programming as an efficient means to save time while managing data, handling files, and engaging with the internet. His interests extend to Rhino3D, Maxsurf C++, AutoCAD, Deep Neural Networks, and Machine Learning, reflecting his versatile skill set. He earned a B.Sc in Naval Architecture & Marine Engineering from BUET, and now he has become a content developer, creating technical content... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo