View Full Version : Need help writng macro to insert Spanish accented characters into a line of text

06-22-2019, 12:16 AM
I am learning Spanish and creating my own dictionary as I go. I want to make a macro that will let me quickly insert one of the accented Spanish characters (like á, for example). I can write a macro that does that, but it will only let me insert the symbol as a single letter in the cell, not after other characters in the word that come before the á. nor can I add additional text in the cell after the insertion. What am I doing wrong and what should the macro read like to allow special characters to be inserted in the middle of a text string being entered by the user?


Leith Ross
06-22-2019, 01:10 PM
Hello hamgarn,

Two things you should do so we can help you: Post the code you have and provide both the operating system and version of Office you are using.

06-22-2019, 02:43 PM
Hello hamgarn,

Two things you should do so we can help you: Post the code you have and provide both the operating system and version of Office you are using.

Oops - sorry. This is the first time I've asked for help.
Brand new computer - does that make it Windows 10?
Excel in Office 365

With the cursor in cell A1 when I write the macro, the code comes out like shown below. I can't get the macro to stop recording after entering the accented a - it won't accept the STOP RECORDING command (or even make it an option in the drop down menu) until I hit ENTER to put the cursor in the next cell, which is why the second line of code shows A2. I don't want to go to the next cell - I just want to insert a special character into a line of text (with text on either side of the special character) in a cell.

Sub á()
' á Macro
' Insert Spanish accented a
' Keyboard Shortcut: Ctrl+Shift+A
ActiveCell.FormulaR1C1 = "á"
End Sub


Leith Ross
06-22-2019, 07:44 PM
Hello hamgarn,,

You made not even need a macro, You can change the input language and keyboard from English to Spanish and back again using the Language Toolbar. Right click the Taskbar then click Toolbars... and select language.


06-22-2019, 09:05 PM
That's an interesting idea but I don't think it will work bc I am making a dictionary, so half the words are in English and half are in Spanish. It looks like it would be a pain to toggle back and forth. Would it be possible to ask for help with doing it via a macro? I only need to be able to input six characters that have accents or tildes, not a whole alphabet.

06-22-2019, 09:13 PM
How do you want to proceed? Use replace like if the sentence in English is tomorrow, change it to mañana?
All you would need is have the english words/letters in column A and the equivalent spanish words in thye cell next to it.
Read it all in an array and go and look for the english words/letters and change to spanish.

06-22-2019, 10:03 PM
No, it isn't a question of replacing an English word with a Spanish word. I need to enter both the English word in one column and the Spanish word in the next column. For example, on the Excel tab for adjectives, I have a column for the English words, were I would enter 'small', and one column over, which is for the Spanish word equivalent, I need to enter the word 'pequeña' and I'd really like not to have to go to either the INSERT SYMBOL menu or the series of strokes ALT 0241, which is disruptive and requires moving one if not both hands away from standard keyboard position (the ALT key is hard to get to and once I move to find it, it's easier to use the number pad). So I really need a macro like CTL SHIFT N to do the ñ bc it's a lot faster and more accurate/reliable.