Modificar código cambiar coma por punto

Tengo el siguiente código:

Sub TXT()

Dim c As Range, r As Range
Dim output As String
For Each r In Range("B6:N65000").Rows
''
'For Each r In Range(Selection.Address(False, False)).Rows
''
For Each c In r.Cells
''
If c.Value = "" Then GoTo exit_for_loop
''
output = output & c.Value & "|"
Next c
output = Mid(output, 1, Len(output) - 1) & vbNewLine
Next r
''-------------------------------------------
exit_for_loop:
output = Mid(output, 1, Len(output) - 1)
''-------------------------------------------

Dim FileName As String

FileName = InputBox(Prompt:="Enter complete path along with file name like c:\file.txt", Title:="Enter file name", Default:="")
If FileName = vbNullString Then Exit Sub
'Open "C:\Documents and Settings\User\Mis documentos\Downloads\" & FileName & ".txt" For Output As #1
Open FileName For Output As #1
Print #1, output
Close
End Sub

El txt que se genera muestra los numero que tienen decimales con coma. Yo quiero que el separador de decimales sea punto. Cambie la configuración regional pero aun así el txt muestra los decimales separados con coma.

Necesito que el separador decimal en el txt sea una punto.

¿

1 respuesta

Respuesta
1

Ya probé la macro y sí me pone el punto como separador decimal.

Sin embargo, le hice un cambio a la macro para ver si te funciona:

Sub TXT()
Dim c As Range, r As Range
Dim output As String
For Each r In Range("B6:N65000").Rows
    ''
    'For Each r In Range(Selection.Address(False, False)).Rows
    ''
    For Each c In r.Cells
        ''
        If c.Value = "" Then GoTo exit_for_loop
        ''
        output = output & c.Value & "|"
    Next c
    output = Replace(output, ",", ".")
    output = Mid(output, 1, Len(output) - 1) & vbNewLine
Next r
''-------------------------------------------
exit_for_loop:
output = Replace(output, ",", ".")
output = Mid(output, 1, Len(output) - 1)
''-------------------------------------------
Dim FileName As String
FileName = InputBox(Prompt:="Enter complete path along with file name like c:\file.txt", Title:="Enter file name", Default:="")
If FileName = vbNullString Then Exit Sub
'Open "C:\Documents and Settings\User\Mis documentos\Downloads\" & FileName & ".txt" For Output As #1
Open FileName For Output As #1
Print #1, output
Close
End Sub

Prueba y me comentas

Saludos. Dante Amor

Si es lo que necesitas.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas