Dear all, please help me.
I have a search frame with three option buttons, now i would change the row involved in the choice.
I'm not very expert with VB, i tried to change the name (Opt1, Opt2, Opt3) but unfortunately it doesn't work.
Please can you help me to try the code to modify?
Thanks a lot!
Salvatore
'================================
'===== Pulsanti frame Trova =====
'================================
Private Sub cmdIniziaRicerca_Click()
Dim ctrl As Control
Dim lCampo As Long
Dim lRif As Long
Dim c As Range
Dim rng As Range
Dim lUltRiga As Long
lCampo = 0
With Me
With .frSelezionaCampo
For Each ctrl In .Controls
If ctrl.Value = True Then
lCampo = Mid(ctrl.Name, _
4, Len(ctrl.Name))
End If
Next
End With
If .txtRicerca <> "" And lCampo <> 0 Then
lUltRiga = sh.Range( _
"A" & Rows.Count).End(xlUp).Row
Set rng = sh.Range("A2:I" & lUltRiga)
For Each c In rng.Range( _
Cells(1, lCampo), _
Cells(lUltRiga, lCampo))
If c.Value = .txtRicerca.Text Then
lRif = 4 - lCampo
.txtID.Value = sh.Cells(c.Row, 1).Value
.cboSheet.Value = sh.Cells(c.Row, 2).Value
.txtInvoice.Value = sh.Cells(c.Row, 3).Value
.cbomonth.Value = sh.Cells(c.Row, 4).Value
.TxtDatum.Value = sh.Cells(c.Row, 5).Value
.TxtCause.Value = sh.Cells(c.Row, 6).Value
.TxtAmount.Value = sh.Cells(c.Row, 7).Value
.cbotype.Value = sh.Cells(c.Row, 8).Value
.cbodebtor.Value = sh.Cells(c.Row, 9).Value
.TxtNote.Value = sh.Cells(c.Row, 10).Value
lRigaAttiva = c.Row
lRigaValoreTrovato = c.Row
Exit For
End If
Next
Else
MsgBox "Nessun dato inserito o nessun campo di ricerca selezionato.", _
vbOKOnly, "Attenzione"
End If
End With
Set ctrl = Nothing
Set c = Nothing
Set rng = Nothing
End Sub
Bookmarks