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

    Scan into all line of txt file... (2000 sr 1)

    ... is possible to scann entire txt file line by line and count a mny value is present?
    In the attaced file count the string:RICHIEDENTE and put in A1 of sheet

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

    Re: Scan into all line of txt file... (2000 sr 1)

    Sub CountRICHIEDENTE()
    ' Substitute correct path and filename
    Const strFile = "C:TestTextfile.txt"

    Dim f As Integer
    Dim strLine As String
    Dim lngCount As Long

    f = FreeFile
    Open strFile For Input As #f
    Do While Not EOF(f)
    Line Input #f, strLine
    If InStr(strLine, "RICHIEDENTE") > 0 Then
    lngCount = lngCount + 1
    End If
    Loop
    Close #f

    Range("A1") = lngCount
    End Sub

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

    Re: Scan into all line of txt file... (2000 sr 1)

    Great! but is possible to count on a fixed posistion, for example only if the string strat into position 9 of txt file?

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

    Re: Scan into all line of txt file... (2000 sr 1)

    Alt dont worry:
    Sub CountRICHIEDENTE()
    ' Substitute correct path and filename
    Const strFile = "C:EPFTI372.EPF"
    Dim f As Integer
    Dim strLine As String
    Dim lngCount As Long

    f = FreeFile
    Open strFile For Input As #f
    Do While Not EOF(f)
    Line Input #f, strLine
    If InStr(strLine, "DEPOSITO/SOTTODEPOSITO:") > 0 Then
    DEPOSITO = Mid(lngCount, 1, 23)
    lngCount = lngCount + 1
    End If
    Loop
    Close #f

    Range("I1") = lngCount
    End Sub

Posting Permissions

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