
Private Sub SaveLab_Click()
Dim iRow As Integer
Application.ScreenUpdating = False
iRow = 7
While Cells(iRow, 1).Value <> ""
iRow = iRow + 1
Wend
Worksheets("Foglio1").Range("A1") = ""
'Cells(iRow, 1) = Cells(iRow, 1).Offset(-1, 0) + 1
Cells(iRow, 1) = TextBox1
Cells(iRow, 2) = TextBox2
Cells(iRow, 3) = ComboBox1.Text
Cells(iRow, 4) = TextBox4
Cells(iRow, 5) = TextBox5
Cells(iRow, 6) = TextBox6
Cells(iRow, 7) = TextBox7
Cells(iRow, 8) = TextBox8
Cells(iRow, 9) = TextBox9
Cells(iRow, 10) = TextBox10
Cells(iRow, 11) = TextBox11
TextBox1.Enabled = False
TextBox2.Enabled = False
ComboBox1.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
TextBox7.Enabled = False
TextBox8.Enabled = False
TextBox9.Enabled = False
TextBox10.Enabled = False
TextBox11.Enabled = False
Cells(iRow, 12) = TextBox15
Cells(iRow, 13) = TextBox13
Cells(iRow, 14) = TextBox14
Cells(iRow, 21) = TextBox16
If CheckBox1.Value = True Then
Cells(iRow, 15) = "X"
End If
If CheckBox3.Value = True Then
Cells(iRow, 16) = "X"
End If
If CheckBox4.Value = True Then
Cells(iRow, 17) = "X"
End If
If CheckBox5.Value = True Then
Cells(iRow, 18) = "X"
End If
If CheckBox2.Value = True Then
Cells(iRow, 19) = "X"
End If
If CheckBox6.Value = True Then
Cells(iRow, 20) = "X"
TextBox12.Enabled = False
End If
TextBox12 = ""
TextBox13 = ""
TextBox14 = ""
TextBox15 = ""
TextBox16 = ""
For N = 1 To 6 'si deselezionano tutte le checkbox
UserForm1.Controls("CheckBox" & N).Value = False
Next
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Frame2.Visible = True
End Sub
Private Sub CommandButton2_Click()
Worksheets("Foglio1").Range("A1") = TextBox1
End Sub
|
Option Explicit
Private Sub SaveLab_Click()
Dim iRow As Long 'integer non è sufficiente
Application.ScreenUpdating = False
iRow = Range("A" & Rows.Count).End(xlUp).Row + 1 'immagino il ciclo while serva a trovare l'utima cella piena
' While Cells(iRow, 1).Value <> ""
' iRow = iRow + 1
' Wend
Worksheets("Foglio1").Range("A1") = ""
'Cells(iRow, 1) = Cells(iRow, 1).Offset(-1, 0) + 1
For i = 1 To 11
If i <> 3 Then
Cells(iRow, i) = userform1.Controls("TextBox" & i)
userform1.Controls("TextBox" & i).Enabled = False
Next i
Next i
Cells(iRow, 3) = ComboBox1.Text
ComboBox1.Enabled = False
Cells(iRow, 12) = TextBox15
Cells(iRow, 13) = TextBox13
Cells(iRow, 14) = TextBox14
Cells(iRow, 21) = TextBox16
If CheckBox1.Value = True Then
Cells(iRow, 15) = "X"
End If
If CheckBox2.Value = True Then
Cells(iRow, 19) = "X"
End If
If CheckBox3.Value = True Then
Cells(iRow, 16) = "X"
End If
If CheckBox4.Value = True Then
Cells(iRow, 17) = "X"
End If
If CheckBox5.Value = True Then
Cells(iRow, 18) = "X"
End If
If CheckBox6.Value = True Then
Cells(iRow, 20) = "X"
TextBox12.Enabled = False
End If
TextBox12 = ""
TextBox13 = ""
TextBox14 = ""
TextBox15 = ""
TextBox16 = ""
For N = 1 To 6 'si deselezionano tutte le checkbox
userform1.Controls("CheckBox" & N).Value = False
Next
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Frame2.Visible = True
End Sub
Private Sub CommandButton2_Click()
Worksheets("Foglio1").Range("A1") = TextBox1
End Sub
|
Sostituisci:
iRow = 7
While Cells(iRow, 1).Value <> ""
iRow = iRow + 1
Wend
Con
iRow = Range("A" & Rows.Count).End(xlUp).Row + 1
Che diventa:
Option Explicit
Private Sub SaveLab_Click()
Dim iRow As Long, i As Long, n As Long
Application.ScreenUpdating = False
iRow = Range("A" & Rows.Count).End(xlUp).Row + 1
Worksheets("Foglio1").Range("A1") = ""
For i = 1 To 11
If i <> 3 Then
Cells(iRow, i) = UserForm1.Controls("TextBox" & i)
UserForm1.Controls("TextBox" & i).Enabled = False
End If
Next i
Cells(iRow, 3) = ComboBox1.Text
ComboBox1.Enabled = False
Cells(iRow, 12) = TextBox15
Cells(iRow, 13) = TextBox13
Cells(iRow, 14) = TextBox14
Cells(iRow, 21) = TextBox16
If CheckBox1.Value = True Then
Cells(iRow, 15) = "X"
End If
If CheckBox2.Value = True Then
Cells(iRow, 19) = "X"
End If
If CheckBox3.Value = True Then
Cells(iRow, 16) = "X"
End If
If CheckBox4.Value = True Then
Cells(iRow, 17) = "X"
End If
If CheckBox5.Value = True Then
Cells(iRow, 18) = "X"
End If
If CheckBox6.Value = True Then
Cells(iRow, 20) = "X"
TextBox12.Enabled = False
End If
TextBox12 = ""
TextBox13 = ""
TextBox14 = ""
TextBox15 = ""
TextBox16 = ""
For n = 1 To 6 'si deselezionano tutte le checkbox
UserForm1.Controls("CheckBox" & n).Value = False
Next n
End Sub
|
Sub StoCalcolo() Dim xlCalc As XlCalculation With Application xlCalc = .Calculation 'controllo come calcola prima di modificare le impostazioni .Calculation = xlCalculationManual 'imposto a manuale End With ''''''''''''''''''''''' '''qui il tuo codice''' '''qui il tuo codice''' '''qui il tuo codice''' ''''''''''''''''''''''' With Application .Calculation = xlCalc 'riporto come prima .Calculate End With 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.ListBox1.AddItem Cells(i, 4) 'esempio a caso, inserico nella listbox il campo "customer" a parità di "Cta Ref"
End If
Next i
End Sub |
=ANNULLA.SPAZI("h t t p: // support . microsoft . com/ k b / 1 4 1 6 9 3 / it") |
