Being able to directly continue writing in a cell after selecting it from a macro

seba_s

New Member
Joined
Apr 16, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I don't know whether the subject line makes sense, but I'll try to specify my problem here again:

As I want to learn portuguese and created my own excel to test my vocabulary, I sometimes need to include special characters like ã or ç. I don't have those on my german keyboard, so I tried to programm hot-keys for that, e.g. by pressing ctrl+a it should give me the ã.
I found the command Application.OnKey "^a", "a_til" which I wrote in the "ThisWorkbook sheet-object" which works fine. When I select a cell and press ctrl+a it gives me the ã at the end of the word which I already have typed.
What I now have to do is press enter, go up to the cell and press F2 to be able to continue writing the last part of the word.

Do you know whether there is a solution to this, so that I can immediately continue writing the word without the detour (enter/up/F2)?

Many thanks and have a nice weekend,
Sebastian
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Welcome!

Can you provide the surrounding code to your Application.OnKey so I know the context in which it is being called?

Also the first thing that comes to mind when doing something like this is the Autohotkey program, which can allow you do to this regardless of where you are typing.
 
Upvote 0
Thanks for the welcome and thanks for the advice on the Autohotkey program. It will probably be helpful, if the VBA approach won't work.

Here is the code which I've tried:

VBA Code:
Public Sub workbook_open()
Application.OnKey "^a", "a_til"
Application.OnKey "^c", "c_ced"
End Sub

VBA Code:
Sub a_til()
ActiveCell.Value = ActiveCell.Value & "ã"
Call ActiveCell.Select
Call AppActivate(Title:=Application.Caption)
End Sub


The last two CALL entries were an idea which I found in another thread, but don't work.

Thanks and have a nice day.
Best Regards,
Sebastian
 
Upvote 0
Would this be a workable solution?

VBA Code:
Public Sub a_til()
ActiveCell.Value = ActiveCell.Value & "ã"
Application.SendKeys ("{F2}")
End Sub
 
Upvote 0
Solution
Thanks, that definitely helped a lot. And it's actually the solution to the subject line.

The next issue is that when I want to write e.g. coração (heart) I write cora, then I need to deactivate the cell to be able to run the hotkey. Do you have a solution to that as well? I tried to include

VBA Code:
Application.SendKeys ("~")
Application.SendKeys ("{UP}")
as the first line of the a_til sub, but unfortunaltely doesn't work.

Many thanks and regards,
Sebastian
 
Upvote 0
I'm sorry I can't help about it, I tried to figure it out by testing and with Google searches, but it seems that running macros is impossible in Excel editing mode (F2).
 
Upvote 0
I'm sorry I can't help about it, I tried to figure it out by testing and with Google searches, but it seems that running macros is impossible in Excel editing mode (F2).
I will refine my previous post. According to Microsoft's official guidelines, macros are disabled in Excel edit mode.
I still tested it by scheduling the macro, but macro starts when only after I exiting the editing mode, so the editing mode prevents all VBA code executions from Excel.
 
Upvote 0

Forum statistics

Threads
1,214,382
Messages
6,119,194
Members
448,874
Latest member
Lancelots

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top