Excel Excel Tab between Controls NOT Keydown > Activate (Worksheet)

Jun 14, 2017
Reaction score
Hello All,

I created a account to ask a semi urgent question for me.
I'm working on a small project for my manager at work and its related to some kind of a appraisal form.
So I created a document full with text boxes made with ActiveX controls.

They're placed within a worksheet so not a user-form...
I have been looking through forums and eventually came to this forum and got a answer to do this.
Public Sub f2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)    If KeyCode = 9 Then f3.Activate
End Sub

This works really well but I stumble into a problem. I got 37 text boxes named f1-f37, this line of code forces me to retype the code 37 times.

I asked colleagues one told me to make a parameter and call the parameter.
I have no experience with this but I think it's not what I want.

What I would like is a piece of code that switches from a f1>f2>f3>f4....
Is this possible in a loop or a piece of code containing variables?

 'Declaration of the fields, something like this
f(x) As textbox

TAB pressed
Activate f(x)
If pressed again.
Activate f(x) ' This will be the next f(x) in the worksheet
 'and so on

I have no expierence in vba as you see above but I hope it is clear enough.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question