Quote
I am trying to format data from a .csv file that has a comma as a
thoushands seperator. How do I remove the thousands seperator.
Sample Data
10/5/2003,Payment,$15.46,86891456
10/15/2003,Payment,"$1,253.32",86891457
9/2/2003,Payment,"$182,256.87",89861458
9/18/2003,Payment,$58.32,89861458
Amounts 1000.00 and larger have " as a text qualifier and all amounts
have a leading $.
I thought I posted this same question a couple of days ago but could
not find my posting.
Here is a response that I have posted before which contains a function that
allows a text string (a record perhaps) to be split correctly around
embedded delimiters... the function allows you to specify the delimiter, the
default is the comma. You will need to provide the optional 2nd argument,
specifying a blank space for it. Here is that previous post:
Rick - MVP
You should be able to use the following function (it returns a String array,
use it like you would Split) to handle this problem (note the comment in the
middle of the code). Notice, it leaves the comma (your delimiter) inside the
quote marks (whether removed or not) alone.
Function SplitAroundQuotes(TextToSplit As String, _
Optional Delimiter As String = ",") As String()
Dim QuoteDelimited() As String
Dim WorkingArray() As String
QuoteDelimited = Split(TextToSplit, """")
For x = 1 To UBound(QuoteDelimited) Step 2
QuoteDelimited(x) = Replace$(QuoteDelimited(x), _
Delimiter, Chr$(0))
Next
TextToSplit = Join(QuoteDelimited, """")
TextToSplit = Replace$(TextToSplit, Delimiter, Chr$(1))
TextToSplit = Replace$(TextToSplit, Chr$(0), Delimiter)
' Uncomment the following line if you
' want the quote marks to be removed
'TextToSplit = Replace$(TextToSplit, """", "")
WorkingArray = Split(TextToSplit, Chr$(1))
SplitAroundQuotes = WorkingArray
End Function
-