Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > BOOK: Excel 2003 VBA Programmer's Reference
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 7th, 2012, 03:11 AM
Registered User
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


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

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
For k = 1 To 205 // columns
Print #1, Cells(j, k).Value & Chr(9)
Next k
End If
j = j + 1
Next j
Close #1


End If
Next i


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
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 .
Old December 10th, 2012, 03:40 AM
Registered User
Join Date: Dec 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Kindly help me on this code . its urgent

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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.