Userform textbox code to work when selected via TAB

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Please can someone help me?

I have the following code below that works in my textbox when selected via the mouse.

VBA Code:
Private Sub TextBoxTOP_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
        TextBoxTOP = ""
        If TextBoxTOP.ForeColor = myGrey Then TextBoxTOP.ForeColor = vbBlack
End Sub

How can I get the code to work the same when using the TAB button to select the textbox?

Thanks

Dan
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi, are you ok?

Use the Event Enter from the button.

VBA Code:
Private Sub TextBoxTOP_Enter()
    TextBoxTOP = ""
    If TextBoxTOP.ForeColor = myGrey Then TextBoxTOP.ForeColor = vbBlack
End Sub

If i understand, when you press tab and enter on the textbox, this code would executed.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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