Instantly retrieve the TextBox value in an Excel cell

Solved
sofienexcel Posted messages 72 Status Member -  
sofienexcel Posted messages 72 Status Member -
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. M-12 Posted messages 1349 Status Member 285
     
    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
  2. sofienexcel Posted messages 72 Status Member
     
    Thank you very much

    it works very well
    0