Hello all,
Based on VBA script below, I can add double-quote cover my string.
So, when I apply the above script for an area of text below;
AAA
BBB
CCC
I would get a result
"AAA"
"BBB"
"CCC"
however, when I save it as a CSV or Text file. The text file show contest as;
"""AAA"""
"""BBB"""
"""CCC"""
what ?!?
I'm also use LEN() to count the lenght of my "AAA" and it return 5.
I try again to leave both "AAA" and AAA in the same file
"AAA"
"BBB"
AAA
and I save the file to CSV. The result is
"""AAA"""
"""BBB"""
AAA
hmm.. so strange!
The result I want is;
"AAA"
"BBB"
AAA
Could anyone point me out what I did is wrong please?
Best Regards,
Flicker
Based on VBA script below, I can add double-quote cover my string.
Code:
Sub Add_DQuote()
Dim r As Range
With Selection
For Each r In Selection
'MsgBox IsNull(r.Value) = True
'MsgBox Mid(r.Value, 1, 1)
'MsgBox Mid(r.Value, Len(r.Value), 1)
'MsgBox Mid(r.Value, 1, 1) = """" And Mid(r.Value, Len(r.Value), 1) = """"
If Len(r.Value) > 0 Then
'If cell is null then mid will error because start character is zero. Use the above If to prevent this error.
If (Mid(r.Value, 1, 1) = """" And Mid(r.Value, Len(r.Value), 1) = """") Then
r.Value = r.Value
Else
If IsNumeric(r.Value) = True Then
r.Value = r.Value
Else
r.Value = """" & r.Value & """"
End If
End If
End If
Next
End With
End Sub
AAA
BBB
CCC
I would get a result
"AAA"
"BBB"
"CCC"
however, when I save it as a CSV or Text file. The text file show contest as;
"""AAA"""
"""BBB"""
"""CCC"""
what ?!?
I'm also use LEN() to count the lenght of my "AAA" and it return 5.
I try again to leave both "AAA" and AAA in the same file
"AAA"
"BBB"
AAA
and I save the file to CSV. The result is
"""AAA"""
"""BBB"""
AAA
hmm.. so strange!
The result I want is;
"AAA"
"BBB"
AAA
Could anyone point me out what I did is wrong please?
Best Regards,
Flicker