![]() |
Insert symbol
A symbol is just a character in a special font. Do you want the symbol to
replace the text in the cell or precede the text in the cell or follow the text in the cell? -- Gary's Student "Frank E" wrote: I have created a macro that inserts a symbol into the active cell. If I have entered text in a cell and try to use my macro it won't work. What code do I need in my macro to enable me to insert my symbol while entering text? |
Insert symbol
In most cases we want to insert the symbol after the text. What we really
want is the ability to press 1 key and insert the symbol before or after the text. "Gary''s Student" wrote: A symbol is just a character in a special font. Do you want the symbol to replace the text in the cell or precede the text in the cell or follow the text in the cell? -- Gary's Student "Frank E" wrote: I have created a macro that inserts a symbol into the active cell. If I have entered text in a cell and try to use my macro it won't work. What code do I need in my macro to enable me to insert my symbol while entering text? |
Insert symbol
Frank
A macro won't run while you're in Edit Mode so you cannot set the cursor in theside the cell text and have your symbol inserted. You can have it inserted at beginning or end of existing text. Sub Add_Symbolt() Dim cell As Range Dim moretext As String Dim thisrng As Range On Error GoTo endit whichside = InputBox("Left = 1 or Right =2") Set thisrng = Range(ActiveCell.Address & "," & Selection.Address) _ .SpecialCells(xlCellTypeConstants, xlTextValues) moretext = Chr(216) If whichside = 1 Then For Each cell In thisrng cell.Value = moretext & cell.Value Next Else For Each cell In thisrng cell.Value = cell.Value & moretext Next End If Exit Sub endit: MsgBox "only formulas in range" End Sub Gord Dibben MS Excel MVP On Thu, 22 Jun 2006 15:40:02 -0700, Frank E wrote: In most cases we want to insert the symbol after the text. What we really want is the ability to press 1 key and insert the symbol before or after the text. "Gary''s Student" wrote: A symbol is just a character in a special font. Do you want the symbol to replace the text in the cell or precede the text in the cell or follow the text in the cell? -- Gary's Student "Frank E" wrote: I have created a macro that inserts a symbol into the active cell. If I have entered text in a cell and try to use my macro it won't work. What code do I need in my macro to enable me to insert my symbol while entering text? |
Insert symbol
Gord,
we tryed the AutoCorrect function and it's working. Thanks for this code. I will try this. I need the coding practice... "Gord Dibben" wrote: Frank A macro won't run while you're in Edit Mode so you cannot set the cursor in theside the cell text and have your symbol inserted. You can have it inserted at beginning or end of existing text. Sub Add_Symbolt() Dim cell As Range Dim moretext As String Dim thisrng As Range On Error GoTo endit whichside = InputBox("Left = 1 or Right =2") Set thisrng = Range(ActiveCell.Address & "," & Selection.Address) _ .SpecialCells(xlCellTypeConstants, xlTextValues) moretext = Chr(216) If whichside = 1 Then For Each cell In thisrng cell.Value = moretext & cell.Value Next Else For Each cell In thisrng cell.Value = cell.Value & moretext Next End If Exit Sub endit: MsgBox "only formulas in range" End Sub Gord Dibben MS Excel MVP On Thu, 22 Jun 2006 15:40:02 -0700, Frank E wrote: In most cases we want to insert the symbol after the text. What we really want is the ability to press 1 key and insert the symbol before or after the text. "Gary''s Student" wrote: A symbol is just a character in a special font. Do you want the symbol to replace the text in the cell or precede the text in the cell or follow the text in the cell? -- Gary's Student "Frank E" wrote: I have created a macro that inserts a symbol into the active cell. If I have entered text in a cell and try to use my macro it won't work. What code do I need in my macro to enable me to insert my symbol while entering text? |
All times are GMT +1. The time now is 12:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com