Página 1 de 1

Macro de Excel para txt terminar sem "|"

Enviado: 21 Ago 2018 às 10:11
por Andrelirasp
Tenho uma macro para isso, só que preciso tirar a opção de terminar sem "|", como posso fazer? Segue a Macro:
Código: Selecionar todos
 ExpExcelTxT()
Dim SrcRg As Range
Dim CurrRow As Range
Dim CurrCell As Range
Dim CurrTextStr As String
Dim ListSep As String
Dim DataTextStr As String

ListSep = "|"
Set SrcRg = ActiveSheet.UsedRange

Open "C:\Users\Carlos André\Desktop\ArqExp.txt" For Output As #1

For Each CurrRow In SrcRg.Rows
    CurrTextStr = ""
    For Each CurrCell In CurrRow.Cells
        CurrTextStr = CurrTextStr & CurrCell.Value & ListSep
    Next
    While Right(CurrTextStr, 1) = ListSep
        CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
    Wend
    CurrTextStr = CurrTextStr & ListSep
    Print #1, CurrTextStr
Next
Close #1
End Sub

Macro de Excel para txt terminar sem "|"

Enviado: 21 Ago 2018 às 10:36
por Reinaldo
O trecho abaixo elimina, para cada linha o ultimo caractere se esse for "|", se deseja que tenha esse caractere, iniba/comente ou exclua essas linhas
Código: Selecionar todos
 ...  
 While Right(CurrTextStr, 1) = ListSep
        CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
    Wend
....

Macro de Excel para txt terminar sem "|"

Enviado: 21 Ago 2018 às 10:39
por Andrelirasp
Agora está salvando com o final assim: |||||||||||||||||||||||

Macro de Excel para txt terminar sem "|"

Enviado: 21 Ago 2018 às 15:01
por Reinaldo
??? pode dispor de um modelo/exemplo