Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB Excel: Read cell data, write it to a text file

Posted on 2000-04-05
2
Medium Priority
?
477 Views
Last Modified: 2008-03-17
I need to read an excel data cell (row) and then print the data (array) to a text file.  Could someone provide a code snippet?
0
Comment
Question by:robjay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 22

Expert Comment

by:ture
ID: 2687069
robjay,

This procedure reads rows 1-3, columns 1-5 from Sheet1 and writes to c:\test\test.txt

Sub ReadAndWrite()
  Dim ws As Worksheet
  Dim r As Long
  Dim c As Long
  Dim f As Integer
 
  Set ws = Sheets("Sheet1")
 
  f = FreeFile
  Open "c:\test\test.txt" For Output As f
 
  For r = 1 To 3
    For c = 1 To 5
      Print #f, ws.Cells(r, c),
    Next c
    Print #f,
  Next r
 
  Close f
End Sub

Ture Magnusson
Karlstad, Sweden
0
 
LVL 22

Accepted Solution

by:
ture earned 400 total points
ID: 2703120
Just a friendly reminder...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question