› Excel e gli applicativi Microsoft Office › [VBA] Cerca con più parametri
-
AutoreArticoli
-
Ah ok ho capito!
ho cambiato solo un paio di righe
Private Sub CommandButton1_Click() Dim ulta As Long Dim area As Range Dim cella As Range Dim firstAddress As String TextBox2 = "" TextBox3 = "" TextBox4 = "" With Sheets("Foglio1") ulta = .Range("A" & Rows.Count).End(xlUp).Row Set area = .Range("A2:A" & ulta) Set cella = area.Find(Replace(TextBox1, ",", "."), , xlValues, xlWhole) If Not cella Is Nothing Then firstAddress = cella.Address Do Set cella = area.FindNext(cella) If cella Is Nothing Or LCase(cella.Offset(0, 1).Text) = "no" Then Exit Do Loop While firstAddress <> cella.Address If LCase(cella.Offset(0, 1).Text) = "no" Then TextBox2 = UCase(cella.Offset(0, 1)) ' Esito TextBox3 = UCase(cella.Offset(0, 2)) ' Scatolone TextBox4 = UCase(cella.Offset(0, 3)) ' Stanza Label9.Caption = UCase(cella.Offset(0, 4)) ' Stato CommandButton4.Enabled = True TextBox2.Enabled = True TextBox3.Enabled = True TextBox4.Enabled = True Else MsgBox "Questa pratica è già esitata", vbExclamation, "ATTENZIONE" TextBox2 = UCase(cella.Offset(0, 1)) ' Esito TextBox3 = UCase(cella.Offset(0, 2)) ' Scatolone TextBox4 = UCase(cella.Offset(0, 3)) ' Stanza Label9.Caption = UCase(cella.Offset(0, 4)) ' Stato CommandButton4.Enabled = True TextBox2.Enabled = True TextBox3.Enabled = True TextBox4.Enabled = True End If Else MsgBox "Nessun valore corrispondente al criterio di ricerca", vbExclamation, "ATTENZIONE" End If End With Set area = Nothing Set cella = Nothing End Sub
Praticamente se c'è "si" mi da prima la textbox che mi avverte che c'è già un esito e poi mi valorizza lo stesso i campi!!
Grazie mille per l'aiuto vecchio frac sei stato gentilissimo come sempre!
Io sono intervenuto in corsa, non dimentichiamo chi ti ha seguito dall'inizio 🙂
(davvero usi dire "pratica già esitata" ? che brutto italiano 😛 )
-
AutoreArticoli