do research on two worksheets with a form in the vba

-2

Good afternoon people! my problem is the following: I have a form with 2 textbox one for students name and one for room and a spreadsheet with two tabs with the same names (txtAlomeAlunos, txtSalaAlunosplan1-name, plan2-sala) I would like to know how to get this information in the 2 spreadsheets and bring it to my txts? Thank you, thank you all

    
asked by anonymous 27.09.2018 / 17:13

1 answer

0

Want to put the name of all students in a TextBox only? Like it's a ComboBox? If you want a ComboBox named after all the students in a worksheet, do the following: Go to the worksheet and select the columns, or rows (depending on how you are) that are the names of your students and right-click. Click "Set Name." Define a name, for example "StudentList". On your Form, create a comboBox (combo box), change the name to cmbListAlunos (or whatever, just for example here). Double-click on the combo and edit this code:

Dim cLoc As Range
    Dim ws As Worksheet
    Set ws = Worksheets("NOME DA SUA PLANILHA")

For Each cLoc In ws.Range("O NOME QUE VOCÊ DEFINIU PARA A SELEÇÃO")
    With Me.cmbListaAlunos 
        .AddItem cLoc.Value
    End With
Next cLoc

This code will add all students to the worksheet in this comboBox. To access another worksheet, you must first activate it. Sheets (POSITION OF THE WORKSHEET example: 1, 2 or 3) .Activate.

Now, if with your system you want to show the students corresponding to a specific room, you can use this example to reflect. Because the code will be very complex to understand if it is posted here.

If this answer was not what you were looking for, just disregard.

    
27.09.2018 / 17:29