How to display the content of an Excel sheet using VBA UserForm

roudiroud Posted messages 36 Status Member -  
roudiroud Posted messages 36 Status Member -
Hello everyone

I am new to VBA programming, and I wanted to know if it is possible to display the contents of an Excel sheet in a userform. The user would only have to press a button to display (in a label) the data present on that sheet.

I’m not sure if this is possible, and I would like to know the VBA code associated with this button?

Thank you in advance.

If you need more details, feel free to ask me.

3 answers

  1. melanie1324 Posted messages 1561 Status Member 156
     
    Hello,

    Yes, it is possible.
    Here is a course on userform.

    To display a cell value, you need to do it via a textbox:

    sub userform1_initialize

    textbox1 = range("A1")
    end sub

    https://www.excel-pratique.com/fr/vba/controles.php
    0
    1. roudiroud Posted messages 36 Status Member
       
      Yes, but with this method, I need to know the size of the data range in advance?
      Because my data changes and doesn't allow me to select only certain cells.

      I don't know if you see the problem?

      Thanks anyway for the info :)
      0
    2. melanie1324 Posted messages 1561 Status Member 156
       
      no, because you can use variables that allow you to adapt your form regardless of the number of lines and columns.
      Through code called VBA
      0
    3. roudiroud Posted messages 36 Status Member
       
      You're welcome :)
      0