Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > BOOK: Excel 2003 VBA Programmer's Reference
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Excel 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Excel 2003 VBA Programmer's Reference by Paul T. Kimmel, Stephen Bullen, John Green, Rob Bovey, Robert Rosenberg, Brian Patterson; ISBN: 9780764556609
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Excel 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 7th, 2012, 02:11 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copying data from excel to txt file with tab delimited

Hi ,
Basically I am writing one macro in Excel 2003 VBA which will copy data from Excel file to .txt file . I want to copy all data from Excel to txt file with a tab delimited . I trying to write the code as below please have a look .

Sub ListSheets()

Dim ws As Worksheet
Dim x As Integer
Dim colcnt As Integer

x = 1

Sheets("Sheet1").Range("A:A").Clear

For Each ws In Worksheets

Sheets("Sheet1").Cells(x, 1) = ws.Name

x = x + 2
Next ws

b = Format(Now(), "MMddyyyy")

For i = 0 To 3
i = i + 1
If Cells(i, 1) = "Sheet1" Then
GoTo end3
Else

Open "C:\AHHNuanceData.txt" For Output As #1
Application.Sheets(Cells(i, 1).Value).Activate

For j = 2 To 65536 // rows
j = j - 1
If Cells(j, 7) = "" Then
GoTo end2
Else
For k = 1 To 205 // columns
Print #1, Cells(j, k).Value & Chr(9)
Next k
End If
j = j + 1
Next j
end2:
Close #1

Application.Sheets("Sheet1").Activate

End If
Next i

end3:

End Sub



The code is working fine just one problem
suppose i have below columns in excel

First_ name Last_name City
--------------------------------
Deepika Vispute Pune
-------------------------------

Then in txt my code is printing
-----------------------
Deepika
Vispute
pune
--------------------------
but I want
----------------------------
Deepika Vispute Pune
-------------------------------
just like in excel .

I am ussing
Print #1
Which is printing each data in new line bydefault
I donít want that

can anyone help me to get the output in proper format as it is in excel
Please help me on this .
Reply With Quote
  #2 (permalink)  
Old December 10th, 2012, 02:40 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kindly help me on this code . its urgent
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying Characters to the Right of a Selected String in a .txt file pdotrun Excel VBA 4 July 12th, 2011 09:52 PM
Write Tab-delimited text file VikramMullick Pro VB.NET 2002/2003 1 May 5th, 2006 11:18 AM
Tab delimited Split ajindal General .NET 1 April 25th, 2006 08:20 AM
Comma delimited file to Excel Sheet vinod_yadav1919 VB How-To 0 August 5th, 2005 10:09 AM
Upload tab delimited into Access? mariakovacs Classic ASP Databases 0 October 10th, 2003 10:54 AM



All times are GMT -4. The time now is 11:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.