ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get macro to copy one row from excel to a text file. Possible? (https://www.excelbanter.com/excel-programming/336703-re-get-macro-copy-one-row-excel-text-file-possible.html)

Bernie Deitrick

Get macro to copy one row from excel to a text file. Possible?
 
Bjorn,

Sorry, sloppy copy and paste work. That last parameter should read:

OtherChar:="*"

Note the ending double quote mark.

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message news:...
Bjorn,

Workbooks.OpenText _
Filename:=Application.GetOpenFilename, _
DataType:=xlDelimited, _
ConsecutiveDelimiter:=False, _
Comma:=False, Other:=True, OtherChar:="*

HTH,
Bernie
MS Excel MVP


"bjorn007" wrote in message
...

Hello!
Thanks for the help. It worked really good, but I have a small question
more.
I can not use Comma (,) as the delimiter (because some of the data that
will be copied into the text file contains comma). So I change it to *.
So far so good!
But when I would like to upload, I get some problems when the data
contains commas. Everything get misplaced. I tried to change
Comma:=True to for example Star:=True or SemiColumn:=True, but it
doesn't work. Do you have any suggestions how to fix it?

And I am really thankful for your help, I would never managed this by
myself. THANK YOU!

Bjorn

Here's the code:

Code 1
myName = ActiveWorkbook.FullName
FName = Application.GetSaveAsFilename( _
Replace(myName, ".xls", ".txt"))
On Error GoTo EndMacro:
FNum = FreeFile
Open FName For Output Access Write As #FNum
Set myRange = Worksheets("database").Range("A6:CL6")
WholeLine = ""
For Each myCell In myRange
WholeLine = WholeLine & myCell.Text & "* " 'Changed to *
Next myCell

WholeLine = Left(WholeLine, Len(WholeLine) - 1)

Print #FNum, Trim(WholeLine)


Code 2
Dim myBook As Workbook
Workbooks.OpenText _
Filename:=Application.GetOpenFilename, _
DataType:=xlDelimited, _
ConsecutiveDelimiter:=False, _
*Comma*:=True ''Here's my problem!!!
Set myBook = ActiveWorkbook
Range("A1").CurrentRegion.Copy
ThisWorkbook.Worksheets("Database").Range("A6").Pa steSpecial _
Paste:=xlPasteValues
myBook.Close False


--
bjorn007
------------------------------------------------------------------------
bjorn007's Profile: http://www.excelforum.com/member.php...o&userid=25959
View this thread: http://www.excelforum.com/showthread...hreadid=393281







All times are GMT +1. The time now is 12:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com