velocizzare userform



  • velocizzare userform
    di dvd78 (utente non iscritto) data: 06/05/2014 13:58:17

    Salve a tutti,
    sono ancora qui per chiedere il vostro aiuto. Ho creato un file excel in cui andranno nserite una lista di attività da due tipi di utenti. Il primo tramite userform richiamata dal pulsante CUS Group inserirà una serie di attività mentre il secondo utente tramite una seconda userform completerà i propri campi in due tempi diversi. funziona tutto come vorrei tranne una particolare lentezza della seconda userform a trascrivere i dati sul foglio. E' possibile velocizzare il tutto??

    Allego codice della seconda userform
     
    Private Sub ComboBox1_Enter()
        Dim r As Integer, Occorrenza As Integer
        Dim col As Collection, v As Variant
        Dim LastRow As Long
        ComboBox1.Clear
        Frame1.Visible = False
    LastRow = Range("A" & Rows.Count).End(xlUp).Row
            Set col = New Collection
            For r = 7 To LastRow
                On Error Resume Next
                If Cells(r, 1) <> "" Then
                    col.Add Cells(r, 1).Value, CStr(Cells(r, 1).Value)
                End If
            Next
            For Each v In col
                Me.ComboBox1.AddItem v
            Next
    
    
    End Sub
    
    Private Sub ComboBox1_Change()
    Dim i As Long, iRow As Long
    iRow = Worksheets("Lista Attività").Range("A" & Rows.Count).End(xlUp).Row
    For i = 7 To iRow
      If Cells(i, 1) = Me.ComboBox1.Value Then
        Me.ComboBox2.AddItem Cells(i, 12) 'esempio a caso, inserico nella listbox il campo "Nr LAB" a parità di "Cta Ref"
      End If
    Next i
    End Sub
    
    Private Sub ComboBox2_Change()
    Dim j As Integer, i As Integer
    Frame1.Visible = True
    ComboBox1.Enabled = False
    iRow = Worksheets("Lista Attività").Range("L" & Rows.Count).End(xlUp).Row
    For i = 7 To iRow
      If Cells(i, 12) = Me.ComboBox2.Value Then
        TextBox1 = Cells(i, 22)
        ComboBox3.Value = Cells(i, 23)
        TextBox6 = Cells(i, 24)
        TextBox2 = Cells(i, 25)
        TextBox3 = Cells(i, 26)
     End If
    Next i
    
    If TextBox1 <> "" Then
    TextBox1.Enabled = False
    End If
    
    If TextBox2 <> "" Then
    TextBox2.Enabled = False
    End If
    
    If TextBox3 <> "" Then
    TextBox3.Enabled = False
    End If
    
    If TextBox6 <> "" Then
    TextBox6.Enabled = False
    End If
    
    If ComboBox3.Value <> "" Then
    ComboBox3.Enabled = False
    End If
    
    
    
    End Sub
    
    Private Sub CommandButton1_Click()
    Dim i As Long, iRow As Long
    Dim j As Long, p As Long, Casella As Variant
    iRow = Worksheets("Lista Attività").Range("L" & Rows.Count).End(xlUp).Row
    For Each Casella In Worksheets("Lista Attività").Range(Cells(7, 12), Cells(iRow, 12))
        If CStr(Casella.Value) = Me.ComboBox2 Then
        Casella.Offset(0, 10) = TextBox1
        Casella.Offset(0, 11) = ComboBox3
        Casella.Offset(0, 12) = TextBox6
        Casella.Offset(0, 13) = TextBox2
        Casella.Offset(0, 14) = TextBox3
        Casella.Offset(0, 15) = ComboBox4
        Casella.Offset(0, 16) = TextBox4
        Casella.Offset(0, 17) = TextBox5
        End If
    Next
          
    For p = 1 To 6
    UserForm2.Controls("TextBox" & p) = ""
    Next p
    
    For j = 2 To 4
    UserForm2.Controls("ComboBox" & j) = ""
    Next j
    
    TextBox1.Enabled = True
    TextBox2.Enabled = True
    TextBox3.Enabled = True
    TextBox4.Enabled = True
    TextBox5.Enabled = True
    TextBox6.Enabled = True
    ComboBox3.Enabled = True
    ComboBox4.Enabled = True
    
    
    End Sub
    
    
    Private Sub CommandButton2_Click()
    Unload Me
    UserForm2.Show
    
    End Sub
    
    Private Sub CommandButton3_Click()
    Unload Me
    End Sub
    
    Private Sub UserForm_Click()
    
    End Sub