Private Sub Cmd_Registra_Click() Dim ur As Long ur = Foglio1.Cells(Rows.Count, 1).End(xlUp).Row With Foglio1 .Cells(ur + 1, 1).Value = Me.ComboBox1.Value .Cells(ur + 1, 2).Value = Me.Txt_Destrizione.Value .Cells(ur + 1, 3).Value = Me.Txt_qta_car.Value .Cells(ur + 1, 4).Value = Me.Txt_qta_scar.Value .Cells(ur + 1, 5).Value = Me.Txt_Prezzo.Value .Cells(ur + 1, 6).Value = Me.Txt_listino.Value .Cells(ur + 1, 7).Value = Me.Txt_sconto.Value .Cells(ur + 1, 10).Value = Me.Txt_data.Value End With Me.Hide MsgBox Me.ComboBox1.Value & " registrato alla riga " & ur + 1, vbInformation, "REGISTRATO" Unload Me End Sub
Private Sub UserForm_initialize() Dim i As Long Dim ur As Long ur = Foglio2.Cells(Rows.Count, 2).End(xlUp).Row For i = 2 To ur Me.ComboBox1.AddItem Foglio2.Range("A" & i).Value Next i End Sub