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
Hard coded formula
Cell reference formula
="("&B5&")"
=$C$4&B8&$C$5
|
GENERIC FORMULA
="("&value&")"
ARGUMENTS GENERIC FORMULA
=open_bracket&value&close_bracket
ARGUMENTS 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. |
Hard coded against single cell
Sub Insert_brackets_around_value_in_a_cell()
'declare variables
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'insert brackets around value in a cell
ws.Range("C5") = "(" & ws.Range("B5") & ")"
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
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")
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
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
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 |
---|---|---|
Insert a value after each word | How to insert characters after each word through the use of an Excel formula or VBA |