Pasar datos de textbox en la fila correspondiente excel vba
Para Dante
Buenos días Dante, necesito su ayuda deseo pasar datos de textbox en las filas correspondientes de acuerdo al combobox que es la condición del grado del alumno, pero siempre se pega en la última fila y no en la fila que le indico.
Private Sub CommandButton1_Click()
Set h1 = Sheets("Hoja2")
If ComboBox1 = "" Or ComboBox2 = -1 Then
MsgBox "Seleccion un grado", vbCritical
Exit Sub
End If
'
u1 = h1.Range("A" & Rows.Count).End(xlUp).Row + 1
If u1 < 2 Then u1 = 2
u2 = h1.Range("A" & Rows.Count).End(xlUp).Row + 1
If u2 < 10 Then u2 = 10
u3 = h1.Range("A" & Rows.Count).End(xlUp).Row + 1
If u3 < 20 Then u3 = 20
u4 = h1.Range("A" & Rows.Count).End(xlUp).Row + 1
If u4 < 30 Then u4 = 30
u5 = h1.Range("A" & Rows.Count).End(xlUp).Row + 1
If u5 < 40 Then u5 = 40
'
Select Case ComboBox1.Value
Case 1
h1.Cells(u1, "A") = Val(TextBox1)
h1.Cells(u1, "B") = combobox1
Case 2
h1.Cells(u2, "A") = Val(TextBox1)
h1.Cells(u2, "B") = combobox1
Case 3
h1.Cells(u3, "A") = Val(TextBox1)
h1.Cells(u3, "B") = combobox1
Case 4
h1.Cells(u4, "A") = Val(TextBox1)
h1.Cells(u4, "B") = combobox1
Case 5
h1.Cells(u5, "A") = Val(TextBox1)
h1.Cells(u5, "B") = combobox1
End SelectPrivate Sub UserForm_Activate() For i = 1 To 5 ComboBox1.AddItem i Next End Sub

1 respuesta
Respuesta de Dante Amor
2