How to display the content of a column in the textbox

Solved
Lynda_123 -  
 Lynda_123 -
Good evening,

Please, I would like to know how to display the content of a column in a textbox.

Thank you in advance for your answers.

3 answers

  1. ptitpanda Posted messages 67 Status Member 8
     
    Good evening,

    Here is a piece of code to achieve what you asked for:

     Private Sub UserForm_Activate() TextBox1.Value = "" For Each valeur In Range("a1:a7") 'Adapt according to the number of rows and the letter of your column TextBox1.Value = TextBox1.Value & Cells(valeur.Row, 1) & vbCr Next valeur End Sub


    WARNING: remember to set "multiline" to TRUE in your textbox properties

    Hope this works for you

    Good night
    1
    1. Lynda_123
       
      Merci bien ptitpanda.
      Please can you explain to me line by line what your code does? Because there are certain functions that I do not understand, such as VbCr.
      0
  2. ptitpanda Posted messages 67 Status Member 8
     
    Hello,

    here is the explanation:
     Private Sub UserForm_Activate() TextBox1.Value = "" 'empties the textbox each time the userform loads (at least it's always updated) For Each value In Range("a1:a7") 'To be adapted according to the number of rows and the letter of your column TextBox1.Value = TextBox1.Value & Cells(value.Row, 1) & vbCr 'fills the textbox by retrieving the value found there and adding the new 'value (next cell in column "A") and adds a line break (vbCr) Next value End Sub


    Good evening
    0