Emulate "Ctrl+[" via VBA

Darker0ne

New Member
Joined
May 6, 2014
Messages
17
Hello!

I'm trying to create a macro, that I can then place in the "Quick Access Toolbar" that does the same as "Ctrl+[".
My Excel is Portuguese, and I can't find a way to make that shortcut working.
So, I thought that I could use the SendKeys VBA command.
But doesn't seem to work either.

I'm writting:

SendKeys "^{]}"

But it just prints the "[", instead of toggling anything.

Can someone help me with this please?

Thank you!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
What does that shortcut do on a Portuguese system?
 
Upvote 0
Hello,

Well, I can't press "Ctrl + [" directly either, because my keyboard is also Portuguese.
So, to do a "[" on a Portuguese keyboard, you have to press "Alt+8" which reflects into a "[".
When I go to Formulas > Trace Precedents and mouse over it, the tooltip seems correct...
"Show arrows that indicate which cells affext the value of the currecntly selected cell. Use Ctrl+[ to navigate to precedents of the selected cell."
I click there once, and the arrows appear. But I wasn't able to make the "Ctrl+[" to work yet, doesn't seem to work if i keep clicked that button, seems I have to shortcut it via keyboard. So, since i can't click it, I thought about emulating the clicks, but seems I'm doing something wrong...

Thank you!
 
Upvote 0
Instead of using sendkeys, try using:

Code:
    On Error Resume Next
    Selection.ShowPrecedents
 
Upvote 0
Hello,

Well, that emulates a click on Formulas > Trace Precedents.
But I want to "navigate" inside that formula, as if i pressed "Ctrl+[" or "Ctrl+]".

That's what I can't do :|

 
Upvote 0
How about
Code:
'  ctrl[
   Selection.DirectPrecedents.Select
'  ctrl]
   Selection.DirectDependents.Select
 
Upvote 0
Hello!

Well, it works, it just selects all the cells.
What I want was simulate the behaviour of "Ctrl+[" that goes part by part of the formula.
Also, with the code above, it only works on the same sheet, if i remember correctly, "Ctrl+[" works on the workbook.

But thank you!
It partially works already!
 
Upvote 0
I simply recorded a macro of me using Ctrl [ & that is what I got.
If that's not what you're after, unfortunately I can't help any further.
 
Upvote 0
Ok.
Is possible for you to check while having cells in multiple sheets?
Does it jump from sheet to sheet?
How can I make the macro stop without giving me any error? Like a... " iferror, then stop macro ".

Thank you for the help!
 
Upvote 0
to stop the error wrap the code in an error handler like
Code:
On Error Resume Next
Selection.DirectPrecedents.Select
On Error GoTo 0
& yes it did take me to other sheets
 
Upvote 0

Forum statistics

Threads
1,215,517
Messages
6,125,290
Members
449,218
Latest member
Excel Master

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