ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Insert a special character before and after a word (https://www.excelbanter.com/excel-discussion-misc-queries/14172-insert-special-character-before-after-word.html)

Venkatesh V

Insert a special character before and after a word
 
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

Peter Rooney

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



"Venkatesh V" wrote:

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



All times are GMT +1. The time now is 05:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com