
'CONTROLLA LA RICERCA DEI DATI'
Private Sub TextBox1_Change()
Dim UltimaRiga As Long, fnd As Range
With Sheets("Gennaio")
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
riga = fnd.Row
With fnd
'Dati da copiare nella TextBox'
'TextBox1 = .Cells(1, 1) 'codice prodotto
TextBox2 = .Cells(1, 2) 'Descrizione prodotto
TextBox3 = .Cells(1, 4) 'Voltaggio
TextBox4 = .Cells(1, 5) 'Voltaggio
End With
End If
End Sub
'Compila settimane mese
Private Sub CommandButton1_Enter()
.Cells(riga, 7) = Val(TextBox6)
.Cells(riga, 8) = Val(TextBox7)
.Cells(riga, 9) = Val(TextBox8)
.Cells(riga, 10) = Val(TextBox9)
.Cells(riga, 11) = Val(TextBox10)
End Sub
|
Option Explicit
Private Sub TextBox1_AfterUpdate()
Dim fnd As Range
Set fnd = Sheets("Gennaio").Range("A:A").Find(what:=Format(TextBox1, "@"))
If Not fnd Is Nothing Then
With fnd
'Dati da copiare nella TextBox'
'TextBox1 = .Cells(1, 1) 'codice prodotto
TextBox2 = .Cells(1, 2) 'Descrizione prodotto
TextBox3 = .Cells(1, 4) 'Voltaggio
TextBox4 = .Cells(1, 5) 'Voltaggio
End With
End If
End Sub
'Compila settimane mese
Private Sub CommandButton1_Click()
With Sheets("XYZ")
.Cells(riga, 7) = Val(TextBox6)
.Cells(riga, 8) = Val(TextBox7)
.Cells(riga, 9) = Val(TextBox8)
.Cells(riga, 10) = Val(TextBox9)
.Cells(riga, 11) = Val(TextBox10)
End With
End Sub
|
Option Explicit
Dim riga As Long
Private Sub TextBox1_AfterUpdate()
Dim fnd As Range
Set fnd = Sheets("Gennaio").Range("A:A").Find(what:=Format(TextBox1, "@"))
If Not fnd Is Nothing Then
With fnd
riga = .Row 'Dati da copiare nella TextBox'
'TextBox1 = .Cells(1, 1) 'codice prodotto
TextBox2 = .Cells(1, 2) 'Descrizione prodotto
TextBox3 = .Cells(1, 4) 'Voltaggio
TextBox4 = .Cells(1, 5) 'Voltaggio
.Cells(riga, 7) = Val(TextBox6)
.Cells(riga, 8) = Val(TextBox7)
.Cells(riga, 9) = Val(TextBox8)
.Cells(riga, 10) = Val(TextBox9)
.Cells(riga, 11) = Val(TextBox10)
End With
End If
End Sub
'Compila settimane mese
Private Sub CommandButton1_Click()
With Sheets("Gennaio")
.Cells(riga, 7) = Val(TextBox6)
.Cells(riga, 8) = Val(TextBox7)
.Cells(riga, 9) = Val(TextBox8)
.Cells(riga, 10) = Val(TextBox9)
.Cells(riga, 11) = Val(TextBox10)
End With
End Sub
|
Option Explicit
Dim riga As Long
Private Sub TextBox1_AfterUpdate()
Dim fnd As Range
Set fnd = Sheets("Gennaio").Range("A:A").Find(what:=Format(TextBox1, "@"))
If Not fnd Is Nothing Then
With fnd
riga = .Row 'Dati da copiare nella TextBox'
'TextBox1 = .Cells(1, 1) 'codice prodotto
TextBox2 = .Cells(1, 2) 'Descrizione prodotto
TextBox3 = .Cells(1, 4) 'Voltaggio
TextBox4 = .Cells(1, 5) 'Voltaggio
End With
End If
End Sub
'Compila settimane mese
Private Sub CommandButton1_Click()
With Sheets("Gennaio")
.Cells(riga, 7) = Val(TextBox6)
.Cells(riga, 8) = Val(TextBox7)
.Cells(riga, 9) = Val(TextBox8)
.Cells(riga, 10) = Val(TextBox9)
.Cells(riga, 11) = Val(TextBox10)
End With
End Sub
|
staff@excelvba.it
Private Sub TextBox1_AfterUpdate()
Dim fnd As Range
Set fnd = Sheets("gennaio").Range("A:A").Find(what:=Format(TextBox1, "@"))
If Not fnd Is Nothing Then
With fnd
riga = .Row 'Dati da copiare nella TextBox'
TextBox2 = .Cells(1, 2) 'Descrizione prodotto
TextBox3 = .Cells(1, 4) 'Voltaggio
TextBox4 = .Cells(1, 5) 'Voltaggio
TextBox12 = .Cells(1, 6) 'Arrivato Mese
TextBox14 = .Cells(1, 14) 'Giacenza
TextBox15 = .Cells(-1, 7) 'per visualizzare la settimana del mese funziona solo per gennaio
TextBox16 = .Cells(-1, 8)
TextBox17 = .Cells(-1, 9)
TextBox18 = .Cells(-1, 10)
TextBox19 = .Cells(-1, 11)
End With
End If
End Sub |
'CONTROLLA LA RICERCA DEI DATI'
Private Sub TextBox1_Change()
Dim UltimaRiga As Long, fnd As Range
With Sheets("Gennaio")
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
riga = fnd.Row
With fnd
'Dati da copiare nella TextBox'
'TextBox1 = .Cells(1, 1) 'codice prodotto
TextBox2 = .Cells(1, 2) 'Descrizione prodotto
TextBox3 = .Cells(1, 4) 'Voltaggio
TextBox4 = .Cells(1, 5) 'Voltaggio
End With
End If
End Sub
'Compila settimane mese
Private Sub CommandButton1_Enter()
.Cells(riga, 7) = Val(TextBox6)
.Cells(riga, 8) = Val(TextBox7)
.Cells(riga, 9) = Val(TextBox8)
.Cells(riga, 10) = Val(TextBox9)
.Cells(riga, 11) = Val(TextBox10)
End Sub
|
Private Sub ComboBox1_Change() 'questa routine viene eseguita ogni volta che si modifica il valore di combobox1
Dim sh As Worksheet
With Me.ComboBox1
For Each sh In ThisWorkbook.Sheets ' controlla che esista un foglio con questo nome
If .Value = sh.Name Then
Me.Caption = " - " & WorksheetFunction.Proper(.Value) & " -" 'aggiorna il titolo della userform
Set shMese = sh 'imposta il foglio selezionato
shMese.Select 'visualizza il mese cercato come sfondo
With shMese
TextBox15 = .Range("G4") 'per visualizzare la settimana del mese funziona solo per gennaio
TextBox16 = .Range("H4")
TextBox17 = .Range("I4")
TextBox18 = .Range("J4")
TextBox19 = .Range("K4")
End With
Exit Sub ' tutto ok, possiamo uscire
End If
Next sh
'se siamo arrivati qui vuol dire che il folgio per il mese selezionato non esiste
MsgBox "Il foglio per il mese selezionato non esiste", vbExclamation
.ListIndex = 0 'riseleziona gennaio
End With
End Sub
Private Sub TextBox1_AfterUpdate()
Dim fnd As Range
Set fnd = shMese.Range("A:A").Find(what:=Format(TextBox1, "@"))
If Not fnd Is Nothing Then
With fnd
riga = .Row 'Dati da copiare nella TextBox'
TextBox2 = .Cells(1, 2) 'Descrizione prodotto
TextBox3 = .Cells(1, 4) 'Voltaggio
TextBox4 = .Cells(1, 5) 'Voltaggio
TextBox12 = .Cells(1, 6) 'Arrivato Mese
TextBox14 = .Cells(1, 14) 'Giacenza
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 obj.Text = "" End If Next |
Private Sub CommandButton2_Click()
Dim i As Byte
For i = 1 To 14
If i <> 5 Then Me.Controls("TextBox" & i) = ""
Next i
Dim obj As Control
End Sub
|
Private Sub CommandButton1_Click()
TextBox1 = Range("A2")
TextBox2 = Range("b2")
TextBox3 = Range("c2")
End Sub
Private Sub CommandButton2_Click()
Range("A2") = TextBox1
Range("b2") = TextBox2
Range("c2") = TextBox3
End Sub |
Private Sub CommandButton2_Click()
LR = Cells(Rows.Count, "A").End(xlUp).Row +1
Range("A" & LR) = TextBox1
Range("b" & LR) = TextBox2
Range("c" & LR) = TextBox3
End Sub |
Private Sub CommandButton1_Click()
For i = 1 To 3
Controls("TextBox" & i).Value = Cells(2, i)
Next i
End Sub
Private Sub CommandButton2_Click()
LR = Cells(Rows.Count, "A").End(xlUp).Row +1
For i = 1 To 3
Cells(LR, i) = Controls("TextBox" & i).Value
Next i
End Sub
|
