Consulting

Results 1 to 7 of 7

Thread: Read Each Row Output Text File

  1. #1
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location

    Question Read Each Row Output Text File

    Hi all,

    How can I read value row by row in Sheet1?
    And output all into a txt file?

    Thanks.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by sheeeng
    How can I read value row by row in Sheet1?
    And output all into a txt file?
    oooh, tricky

    Actually, it is surprisingly simple


    Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename:="C:\myTest\Sheeeng.txt", _
                              FileFormat:=xlText, _
                              CreateBackup:=False
        Application.DisplayAlerts = True

  3. #3
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Sorry, xld. Not really what I need.
    Maybe I should clarify a bit.

    eg.
    the macro reads through the each row, output in msgbox the value in the cell, output file, and read the next cell, and so on.......

    Most important is that it can read row by row and display the row datas....

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by sheeeng
    Sorry, xld. Not really what I need.
    Maybe I should clarify a bit.

    eg.
    the macro reads through the each row, output in msgbox the value in the cell, output file, and read the next cell, and so on.......

    Most important is that it can read row by row and display the row datas....
    Just precede it by a loop to output all


    Dim iLastRow As Long
    Dim i As Long

    iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
    For i = 1 To iLastRow
    Msgbox Cells(i,"A").Value
    Next i

  5. #5
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    What does the code below does?

    Cells(Rows.Count,"A").End(xlUp).Row

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by sheeeng
    What does the code below does?

    Cells(Rows.Count,"A").End(xlUp).Row
    Finds the last non-empty row in column A.

  7. #7
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Good. Another solved by alll your help.
    Thanks a lot!!

Posting Permissions

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