I have an ActiveX text box on a worksheet. This box is filled from code that runs on another worksheet. It is not filled from a cell. I want to prevent a user from clicking in the text box and changing anything.

If I set the Enabled property to False, the data in the box is greyed out which I don't want.

There is no event (i.e. TextBox_OnFocus) that I know of that can give an error message and then select another text box.

I had though about code similar to the following:

Private Sub TextBox6_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode <> 0 Then
        MsgBox "You cannot manually enter data in this box", vbCritical, "Wrong input"
            TextBox7.Activate
    End If
End Sub
This doesn't kill the key entry though. It still puts whatever was typed into the text box, it just tells the user they weren't supposed to do this.

I tried combining this with a _LostFocus event that reinputs the correct value in the text box but for some reason exiting the message box and having the code activate TextBox7 isn't being interpreted as a LostFocus event.

Any help would be apprecited. Either no grey text in a disabled text box or a kill key command in the KeyDown event or a way to get the LostFocus event to run properly would be appreciated.

Thank you,

Brian