Insert a special character before and after a word

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
For ex: In a cell, lets say the value is 'Microsoft'. i want to create a
button or a macro such that, if i click that it should insert ')' before &
after that word.

How to do it?

Rgds,
Venkatesh
 
Hi, Venkatesh

Try selecting the cell to be modified and running this:

Sub AddBrackets()
Selection.Value = "(" & Selection.Formula & ")"
End Sub

If you want to modify a range of cells, select them then run this:

Sub AddBracketsToRange()
Dim CellToModify As Object
For Each CellToModify In Selection
CellToModify.Formula = "(" & CellToModify.Formula & ")"
Next CellToModify
End Sub

Hope this helps

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top