Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Found string 6 right... (2000 sr 1)

    Edited by HansV. Don't use <!t>[script] tags for code - it is unreadable. Use <!t>[code] or <!t>[pre] tags instead.

    I have in this code to search in a column E a value...
    Now in column E i have all value in this format:
    ...
    4500154789
    4501500015
    6582000145
    ...

    the first 4 character idenntify Agency and the next 6 the Account i want to find only in the next 6 character...

    Naturally if i insert in textbox 58 the code found 6 58 2000145...

    How to limit the searching only to last 6 character?

    <pre>Private Sub CommandButton10_Click()

    Dim T As String
    Dim INTRESULT As Integer

    If TextBox27.Value = "" Then
    MsgBox "INSERIRE UN VALORE PER LA RICERCA NEL CAMPO NOMINATIVO!", vbCritical
    Exit Sub
    End If

    Set CONTOCORR = ActiveSheet.Range(Cells(2, 5), Cells(2, 5).End(xlDown))

    For Each CL In CONTOCORR

    CC = Me.TextBox27.Text

    If CL.Value Like "*" & CC & "*" Then

    INTRESULT = 1
    DOMANDA = MsgBox("HO TROVATO " & CL.Value & ", VUOI FERMARTI ?", vbYesNo)
    If DOMANDA = vbYes Then

    INTRESULT = 2

    Me.TextBox27.Value = ""

    T = CL.Row

    Me.ScrollBar1.Value = T
    Me.TextBox1.Value = Sheets("GAF").Cells(T, "A").Value
    Me.TextBox2.Value = Sheets("GAF").Cells(T, "F").Value
    Me.TextBox3.Value = Sheets("GAF").Cells(T, "G").Value
    Me.TextBox8.Value = Sheets("GAF").Cells(T, "P").Value
    Me.TextBox10.Value = Sheets("GAF").Cells(T, "H").Value
    Me.TextBox11.Value = Sheets("GAF").Cells(T, "I").Value
    Me.TextBox12.Value = Sheets("GAF").Cells(T, "C").Value
    Me.TextBox15.Value = Sheets("GAF").Cells(T, "J").Value
    Me.TextBox16.Value = Sheets("GAF").Cells(T, "B").Value
    Me.TextBox18.Value = Sheets("GAF").Cells(T, "D").Value
    Me.TextBox19.Value = Right((Sheets("GAF").Cells(T, "E").Value), 6)
    Me.TextBox24.Value = Sheets("GAF").Cells(T, "K").Value

    If Sheets("GAF").Cells(RIGA, "X").Value = "X" Then
    Me.TextBox26.Value = "NO"
    Else
    Me.TextBox26.Value = "SI"
    End If

    Me.TextBox6 = Sheets("GAF").Cells(RIGA, "M").Value
    Exit For
    End If
    End If
    Next

    Select Case INTRESULT
    Case 0 ' not found
    Me.TextBox27.Value = ""
    MsgBox "NESSUN NOMINATIVO TROVATO CON IL VALORE: " & CC & "", vbInformation
    Case 1 ' all found
    Me.TextBox27.Value = ""
    MsgBox "TUTTI I NOMINATIVI CON " & CC & " SONO STATI VISUALIZZATI.", vbInformation
    Case 2 ' stopped
    ' do nothing?
    End Select

    End Sub
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Found string 6 right... (2000 sr 1)

    Use

    If Right(CL.Value, 6) Like "*" & CC & "*" Then

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Found string 6 right... (2000 sr 1)

    Work tks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •