Highlighting selected textbox

Chuck6475

Board Regular
Joined
Sep 30, 2012
Messages
126
2003 / w7.

I have a series of textbox(s) in which the user enters data. I'm using the data that the user enters to control whether I advance to the next textbox in the series using SetFocus. It works great but...... the cursor is not (setfocus vertical line flash) is not easy to see, I'd like to change the color of the background of the textbox when it is the "selected" cell and change it back upon advancing to the next cell.

Here is an example of the code:

Code:
Private Sub FHole1_Change()
    If Not IsNumeric(FHole1.Text) Then Exit Sub
    If Len(FHole1.Text) = 1 And FHole1.Text <> 1 Then FHole2.SetFocus
    If Len(FHole1.Text) = 2 Then FHole2.SetFocus

        
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You can set the TextBox's BackColor like this:

Code:
Private Sub FHole1_Change()
    If Not IsNumeric(FHole1.Text) Then Exit Sub
    If (Len(FHole1.Text) = 1 And FHole1.Text <> 1) Or Len(FHole1.Text) = 2 Then
        FHole2.SetFocus
        FHole2.BackColor = &H8080FF
    End If
End Sub

To reset it use &H80000005&.
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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