Command Button OK VBA Excel

Feng -  
Clark...kent Posted messages 50 Status Member -
Hello,

I am currently programming my OK button command. In my userform window, I have created several text boxes for the user to input data.
I want to be able to retrieve this data and put it into my function variables (Actually, this data is used to fill in the rows of my Excel sheet)....
Since I do not really know VBA very well.... in terms of syntax, I really don't know how to do it, and I can't seem to find any examples of this type of code.
Could someone please help me??
Thank you very much for your help!

Configuration: Windows XP / Firefox 10.0.4

1 answer

  1. Clark...kent Posted messages 50 Status Member 2
     
    Hello,

    So you created a textbox in your form.
    If so, rename it in its property.
    Example: TxtNom

    To retrieve the value contained: TxtNom.Value = Range("A1")

    Let me know if this is really what you want.
    0
    1. Feng
       
      In fact, I am doing this for the "OK button command".....
      And the code I wrote is:
      'The position in the Excel sheet to fill
      Position = Worksheets("Control System I O list").Range("P1").End(xlUp).Row

      'Storing the value from the text box
      Worksheets("Control System I O list").Range("P" & Position).Value = _
      frm_ADRESSE.CompanyProjectNumber.Value
      'Clearing the text box
      frm_ADRESSE.CompanyProjectNumber.Value = ""


      The "CompanyProjectNumber" is the name of my textbox.

      But it doesn't work, it gives me an "object required" error on
      Worksheets("Control System I O list").Range("P" & Position).Value = _
      frm_ADRESSE.CompanyProjectNumber.Value


      And I don't see where the error is....
      0
    2. Clark...kent Posted messages 50 Status Member 2
       
      The post is a bit dated, but attach your file; it will be easier.
      0