Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dk dk is offline
external usenet poster
 
Posts: 129
Default Text Export macro modification?

I'm exporting text to an application that requires that when a field is
empty there should be nothing between the seperators for that field. Clear
as mud?
When Field3 is empty, my text file needs to read; fld1,fld2,,fld4,fld5...
I'm using a wonderful macro from Chip Pearson at
http://www.cpearson.com/excel/ImpText.aspx
However, my empty fields end up in the text file as fld1,fld2,"",fld4,fld5
Below is part of the macro. How can I modify the code leave the field
"empty" (without the quotes)?
Thanks.

For RowNdx = StartRow To EndRow
WholeLine = ""
For ColNdx = StartCol To EndCol
If Cells(RowNdx, ColNdx).Value = "" Then
CellValue = Chr(34) & Chr(34)
Else
CellValue = Cells(RowNdx, ColNdx).Text
End If
WholeLine = WholeLine & CellValue & Sep
Next ColNdx
WholeLine = Left(WholeLine, Len(WholeLine) - Len(Sep))
Print #FNum, WholeLine
Next RowNdx


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Text Export macro modification?

hi,
this line
CellValue = Chr(34) & Chr(34)
chr(34) is a double quote(") so the macro itself is putting the quotes in.
try this..
CellValue = ""
and see what happens.

Regards
FSt1

"DK" wrote:

I'm exporting text to an application that requires that when a field is
empty there should be nothing between the seperators for that field. Clear
as mud?
When Field3 is empty, my text file needs to read; fld1,fld2,,fld4,fld5...
I'm using a wonderful macro from Chip Pearson at
http://www.cpearson.com/excel/ImpText.aspx
However, my empty fields end up in the text file as fld1,fld2,"",fld4,fld5
Below is part of the macro. How can I modify the code leave the field
"empty" (without the quotes)?
Thanks.

For RowNdx = StartRow To EndRow
WholeLine = ""
For ColNdx = StartCol To EndCol
If Cells(RowNdx, ColNdx).Value = "" Then
CellValue = Chr(34) & Chr(34)
Else
CellValue = Cells(RowNdx, ColNdx).Text
End If
WholeLine = WholeLine & CellValue & Sep
Next ColNdx
WholeLine = Left(WholeLine, Len(WholeLine) - Len(Sep))
Print #FNum, WholeLine
Next RowNdx



  #3   Report Post  
Posted to microsoft.public.excel.programming
dk dk is offline
external usenet poster
 
Posts: 129
Default Text Export macro modification?

That did it!
Thanks very much.
DK

"FSt1" wrote in message
...
hi,
this line
CellValue = Chr(34) & Chr(34)
chr(34) is a double quote(") so the macro itself is putting the quotes in.
try this..
CellValue = ""
and see what happens.

Regards
FSt1

"DK" wrote:

I'm exporting text to an application that requires that when a field is
empty there should be nothing between the seperators for that field.
Clear
as mud?
When Field3 is empty, my text file needs to read;
fld1,fld2,,fld4,fld5...
I'm using a wonderful macro from Chip Pearson at
http://www.cpearson.com/excel/ImpText.aspx
However, my empty fields end up in the text file as
fld1,fld2,"",fld4,fld5
Below is part of the macro. How can I modify the code leave the field
"empty" (without the quotes)?
Thanks.

For RowNdx = StartRow To EndRow
WholeLine = ""
For ColNdx = StartCol To EndCol
If Cells(RowNdx, ColNdx).Value = "" Then
CellValue = Chr(34) & Chr(34)
Else
CellValue = Cells(RowNdx, ColNdx).Text
End If
WholeLine = WholeLine & CellValue & Sep
Next ColNdx
WholeLine = Left(WholeLine, Len(WholeLine) - Len(Sep))
Print #FNum, WholeLine
Next RowNdx





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Modification Carl Excel Worksheet Functions 2 August 30th 06 01:53 PM
macro to export a range to a text file? [email protected] Excel Programming 4 July 21st 06 02:25 PM
Macro to export as Text, only the results not the formula [email protected] Excel Discussion (Misc queries) 1 July 6th 06 04:41 PM
text modification jtaiariol Excel Worksheet Functions 1 November 17th 05 01:27 PM
Macro modification HJ Excel Programming 6 November 3rd 04 07:37 PM


All times are GMT +1. The time now is 06:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"