Results 1 to 7 of 7

Macro, to remove commas and remove speach marks

Threaded View

  1. #1
    Registered User
    Join Date
    12-13-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    42

    Macro, to remove commas and remove speach marks

    Hi Guys.

    I have a csv file which is converted to a .txt file. Please find the txt file attached. The other csv is having difficulty uploading. Ill try on a seperate post to try and upload this.

    I need to take the csv file and write some code to it so it writes to either:

    1. Another csv file or a txt file directly without any of the trailing commas at the end of each line. )Line 1,3,5,7 etc have 10 or so commas which dont need to be there. Also line 2, 4, 6 etc contains an amount with speach marks, The speach mark in line 2 number is "3,543.00".

    I was able to use some code which takes one file and writes to another which removes the comma's, this works, however i now need to edit the code so that it picks up the " speach marks " and removes them also :

    Dim TextLine As String, comma As String
        comma = ","
       
        Close #1
        Close #2
        
        Open "c:\Dubai Payslips\input.csv" For Input As #1
        Open "c:\Dubai Payslips\output.csv" For Output As #2
        
        Do While Not EOF(1)
            Line Input #1, TextLine
            
            l = Len(TextLine)
            For i = 1 To l
                If Right(TextLine, 1) = comma Then
                    TextLine = Left(TextLine, Len(TextLine) - 1)
                End If
            Next
            
            Print #2, TextLine
        Loop
        Close #1
        Close #2
    Does anyone know how i can do this?

    Regards

    Shil
    Attached Files Attached Files
    Last edited by Cutter; 07-30-2012 at 01:24 PM. Reason: Added code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1