Sometimes we need to add brackets into cells to enclose texts for some reasons. If we only add brackets for one single cell, it is very easy, but if there are a column of cells need to add brackets, how can we do? This article will show you three simple ways to add brackets by Formula, Format Cells Function and VBA code.
In condition, we prepare a table to save Year.
We use this sample to do demonstration.
Table of Contents
1. Add Brackets for Cells by Formula in Excel
Step 1: Select another column for example column B, in cell B2 enter =”(“&A2&”)”.
Step 2: Press Enter to get result.
Step 3: Select cell B2 which contains the formula, drag it and fill the cells B3 and B4. Then we can get a new column with brackets enclose the texts. You can copy the result to cover column A by paste with value.
2. Add Brackets for Cells by Format Cells Function in Excel
Step1: Select all ranges you want to add brackets for them. In this case select A2, A3 and A4.
Step2: Right click your mouse, select ‘Format Cells…’.
Step3: On Format Cells window, select Custom under Category list.
Step4: In Type, enter “(“General”)”. Then you can find 2017 is changed to (2017) in Sample.
If the value in cell is Text, you can enter “(“@”)” in type instead.
Step5: Click OK to get result. All cells are enclosed with brackets properly.
3. Add Brackets for Cells by VBA Code in Excel
Step1: open your excel workbook and then click on “Visual Basic
” command under DEVELOPER
Tab, or just press “ALT+F11
” shortcut.
Step2: then the “Visual Basic Editor
” window will appear.
Step3: click “Insert
” ->”Module
” to create a new module.
Step4: paste the below VBA code into the code window. Then clicking “Save
” button.
Sub addbrackets()
Set myRange = Application.Selection
Set myRange = Application.InputBox("please select a Range", "addbrackets", myRange.Address, Type:=8)
For Each myCell In myRange
myCell.Value = "(" & myCell.Value & ")"
Next
End Sub
Step5: back to the current worksheet, click on Macros
button under Code
group. then click Run
button.
Step6: you need to type one password to protect your current worksheet, click on Ok
button.
Step7: you would see that the selected cells have been inserted brackets around text.
4. Video: Add Brackets for Cells
This tutorial video will show you three ways to add brackets to cells in Excel.
5. SAMPLE FIlES
Below are sample files in Microsoft Excel that you can download for reference if you wish.