Instantly retrieve the TextBox value in an Excel cell

Solved
Hello,

I want to set the value of a textbox in a cell. I'm using the following code:
Sheets("Sheet1").Range("f2").Value = UserForm1.TextBox1.Value
It only works if I exit the user form and click on another cell (I think it's a refresh issue). Is there something missing for the code to work instantly without needing to click on a cell?

Thank you.

2 answers

  1. Hello,
    two possibilities
    after changing the textbox
    Private Sub TextBox1_AfterUpdate() Sheets("Feuil1").Range("f2").Value = UserForm1.TextBox1.Value End Sub 

    on the textbox change
    Private Sub TextBox1_Change() Sheets("Feuil1").Range("f2").Value = UserForm1.TextBox1.Value End Sub
    1
    1. Thank you very much

      it works very well
      0