Insert brackets around value in a cell

This tutorial shows how to insert brackets around values captured in a cell through the use of a & sign or VBA

EXCEL FORMULA 1. Insert brackets around value in a cell using the & sign

EXCEL

Hard coded formula
Insert brackets around value in a cell
Cell reference formula
Insert brackets around value in a cell
="("&B5&")"
=$C$4&B8&$C$5
GENERIC FORMULA

="("&value&")"

ARGUMENTS
value: A cell that captures the value between which you want to insert brackets.

GENERIC FORMULA

=open_bracket&value&close_bracket

ARGUMENTS
value: A cell that captures the value between which you want to insert brackets.
open_bracket: An open bracket sign.
close_bracket: An close bracket sign.

EXPLANATION

This formula uses the the & sign to insert brackets between a specific value or string of values that are captured in a specific cell.

Click on either the Hard Coded or Cell Reference button to view the formula that either has the bracket signs directly entered in the formula or referenced to a cell that captures the open and close bracket signs.

VBA CODE 1. Insert brackets around value in a cell using VBA

VBA

Hard coded against single cell
Sub Insert_brackets_around_value_in_a_cell()
'declare variables
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'insert brackets around value in a cell
ws.Range("C5") = "(" & ws.Range("B5") & ")"

End Sub

Cell reference against single cell
Sub Insert_brackets_around_value_in_a_cell()
'declare variables
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'insert brackets around value in a cell
ws.Range("C8") = ws.Range("C4") & ws.Range("B8") & ws.Range("C5")

End Sub

Hard coded against range of cells
Sub Insert_brackets_around_value_in_a_cell()
'declare variables
Dim ws As Worksheet
Set ws = Worksheets("Analysis")

'insert brackets around value in a cell

For x = 5 To 7

ws.Range("C" & x) = "(" & ws.Range("B" & x) & ")"
Next x

End Sub

Cell reference against range of cells
Sub Insert_brackets_around_value_in_a_cell()
'declare variables
Dim ws As Worksheet
Set ws = Worksheets("Analysis")

'insert brackets around value in a cell

For x = 8 To 10

ws.Range("C" & x) = ws.Range("C4") & ws.Range("B" & x) & ws.Range("C5")
Next x

End Sub

RELATED TOPICS

Related Topic Description Related Topic and Description
How to insert characters after each word through the use of an Excel formula or VBA