Results 1 to 8 of 8

read a line from external text files on a random basis

Threaded View

  1. #1
    Registered User
    Join Date
    05-10-2015
    Location
    France
    MS-Off Ver
    10
    Posts
    58

    read a line from external text files on a random basis

    the random number called "RandomNum" got claculated from the total number of lines in each file. Each line is of the same exact length. I wish to read a different line each time.
    My issue is where to place that random number in my code? Every try it generate an error.

    [Code)
        Open Filename For Input As #1
        If Err <> 0 Then
            MsgBox "Not found: " & Filename, vbCritical, "ERROR"
            Exit Sub
        End If
        r = 0
        c = 0
        txt = 0
        Application.ScreenUpdating = False
            Line Input #1 Data(RandomNum)   ' get the data on a random basis from the file
            For i = 1 To 81
                Char = Mid(Data, i, 1)
                If Char <> Chr(34) Then
                    Rng.Cells(i) = Char
                End If
            Next i
        Close #1    ' #1 is the reference of the file
        Application.ScreenUpdating = True
    [/Code)]
    Last edited by Fotis1991; 05-15-2015 at 02:17 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA excel read random line from text file
    By VBAxxx in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-14-2017, 04:15 AM
  2. [SOLVED] IMPORTING TEXT FILES TO EXCEL - Multiple Multi-line text files, each in a new column
    By wrenchfry in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-23-2014, 08:37 PM
  3. IMPORTING TEXT FILES TO EXCELL - Multiple Multi line text files
    By Toxicca in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-12-2014, 09:56 AM
  4. Read the text in a single cell line by line.
    By moon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2010, 06:23 AM
  5. Macro to read External Files WITH Similar Names
    By thunderfoot in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2005, 09:39 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1