Salvare da texbox a celle



  • Salvare da texbox a celle
    di rotella data: 05/02/2014 09:18:02

    Ciao a Tutti con l'aiuto di molti di voi sono a buon punto devo solo far funzionare l'inserimento dei dati che da textbox vadano a salvarsi nelle celle.
    La textbox che mi serve correggere dopo ave richiamato un codice è quella della QUANTITA'. Mi potete dare un aiuto.


     
    'CONTROLLA LA RICERCA DEI DATI'
    Private Sub TextBox1_Change()
     Dim UltimaRiga As Long, fnd As Range
         With Sheets("Foglio1")
             UltimaRiga = .Range("A" & Rows.Count).End(xlUp).Row
             Set fnd = .Range("A1:A" & UltimaRiga).Find(what:=Format(TextBox1, "@"))
         
         End With
        
         If Not fnd Is Nothing Then
             With fnd
                 'Dati da copiare nella TextBox'
                 TextBox2 = .Cells(1, 1) 'Codice'
                 TextBox3 = .Cells(1, 3) 'Descrizione'
                 TextBox4 = .Cells(1, 2) 'Quantita'
                 TextBox5 = .Cells(1, 4) 'Scaffale'
                 TextBox6 = .Cells(1, 5) 'Ubicazione'
             End With
         End If
              End Sub
        
    'COMANDO PER PULIRE TEXTBOX'
     Private Sub CommandButton2_Click()
     Dim obj As Control
     For Each obj In Me.Controls
     If TypeOf obj Is MSForms.TextBox Then ' se si trattasse di una combobox , basta chiamare l'oggetto
     obj.Text = ""
     End If
     Next
     TextBox1.SetFocus
     End Sub
    'Tasto per Chiudere e Salvare'
    Private Sub CommandButton3_Click()
    'Application.Quit
    'ActiveWorkbook.Close SaveChanges:=True
    Unload Me
    End Sub
    
    'Tasto per Salvare dati modificati'
    Private Sub CommandButton4_Click()
    TextBox4.SetFocus
    
    End Sub
    'Visualizzare Calcolatrice'
    Private Sub CommandButton5_Click()
     Dim CALC
     CALC = Shell("C:WINDOWSSystem32CALC.EXE", 1)
     End Sub
    
    
    Private Sub Label1_Click()
    
    End Sub
    
    Private Sub Label2_Click()
    
    End Sub
    
    Private Sub Label3_Click()
    
    End Sub
    
    Private Sub Label4_Click()
    
    End Sub
    
    
    
    
    Private Sub TextBox4_Change()
    
    End Sub
    
    Private Sub TextBox5_Change()
    
    End Sub
    
    'CONTROLLA SE CI SONO LETTERE NELLA TEXTBOX'
    'Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
     'If Not IsNumeric(TextBox1.Text) Then      ' se il campo non contiene dei numeri verrà visualizzato il messaggio
     'MsgBox "Inserire solo numeri!", Title:="Errore"
     'End If
     'End Sub
    
    
    Private Sub UserForm_Click()
    
    End Sub
    



  • di rotella data: 05/02/2014 09:37:20

    In allegato c'è il file se può esservi di aiuto



  • di patel data: 05/02/2014 10:14:59

    Se ho capito bene vuoi modificare solo la quantità, quindi modifiva le tue sub così , inserisci un modulo standard e scrivici
    Public riga

     
    Private Sub CommandButton4_Click()
       Cells(riga, 2) = Val(TextBox4)
    End Sub
    Private Sub TextBox1_Change()
     Dim UltimaRiga As Long, fnd As Range
         With Sheets("Foglio1")
             UltimaRiga = .Range("A" & Rows.Count).End(xlUp).Row
             Set fnd = .Range("A1:A" & UltimaRiga).Find(what:=Format(TextBox1, "@"))
             riga = fnd.Row
         End With
        
         If Not fnd Is Nothing Then
             With fnd
                 'Dati da copiare nella TextBox'
                 TextBox2 = .Cells(1, 1) 'Codice'
                 TextBox3 = .Cells(1, 3) 'Descrizione'
                 TextBox4 = .Cells(1, 2) 'Quantita'
                 TextBox5 = .Cells(1, 4) 'Scaffale'
                 TextBox6 = .Cells(1, 5) 'Ubicazione'
             End With
         End If
     End Sub






  • di Rotella (utente non iscritto) data: 05/02/2014 11:15:17

    Ciao Patel Grazie della risposta ho inserito le tue correzioni ma non funziona ti allego il file. Grazie ancora



  • di Rotella (utente non iscritto) data: 05/02/2014 11:18:21

    Scusa ho visto solo ora il tuo file aggiornato



  • di Rotella (utente non iscritto) data: 05/02/2014 14:56:08

    Ciao Patel ho un acuriosità come mai il programmino che hai visto mi funziona tutto bene lo porto su un office 2003 è mi da un errore in questa riga di comando [riga = fnd.Row]. Ciao Grazie
     
    Private Sub CommandButton4_Click()
       Cells(riga, 2) = Val(TextBox4)
    End Sub
    Private Sub TextBox1_Change()
     Dim UltimaRiga As Long, fnd As Range
         With Sheets("Foglio1")
             UltimaRiga = .Range("A" & Rows.Count).End(xlUp).Row
             Set fnd = .Range("A1:A" & UltimaRiga).Find(what:=Format(TextBox1, "@"))
             riga = fnd.Row
         End With
        
         If Not fnd Is Nothing Then
             With fnd
                 'Dati da copiare nella TextBox'
                 TextBox2 = .Cells(1, 1) 'Codice'
                 TextBox3 = .Cells(1, 3) 'Descrizione'
                 TextBox4 = .Cells(1, 2) 'Quantita'
                 TextBox5 = .Cells(1, 4) 'Scaffale'
                 TextBox6 = .Cells(1, 5) 'Ubicazione'
             End With
         End If
     End Sub



  • di patel (utente non iscritto) data: 05/02/2014 15:22:36

    non ho il 2003 e non ti so dire, controlla il tipo di errore, lancia la macro con F8 step by step e controlla se fnd viene trovato o è = nothing



  • di Rotella (utente non iscritto) data: 06/02/2014 08:21:33

    Risolto Grazie.