+ Reply to Thread
Results 1 to 3 of 3

Search and replace a line of text in a CSV file

  1. #1
    Forum Contributor
    Join Date
    07-21-2009
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2010
    Posts
    117

    Search and replace a line of text in a CSV file

    Hi, I was wondering how I would go about finding and replacing a line of text in a CSV file on a server.

    Basically I have two variables in my Workbook:

    1 – Unique Username
    2 – Time

    I would like to run a macro which prompts for the username to be entered and the new time.

    Once this information is gathered, it can search the CSV file for the Unique Username and replace the line of text with the new information

    The CSV file is formatted like this:

    “Unique Username”,”Time”

    Is there some VB code which could do this?

    Thanks,
    Tom

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Search and replace a line of text in a CSV file

    Could be done this way

    Please Login or Register  to view this content.
    If this is your csv

    Tom,Time
    Richard,Time
    Harry,Time
    Alistair,Time


    Regards
    Alistair

    P.S.

    If you need a Userform to list all the names in the CSV and allow the user to select one then add the new data.
    Please let me know

    Regards
    Alistair
    Last edited by Marcol; 02-16-2010 at 08:53 AM. Reason: P.S. Added

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Search and replace a line of text in a CSV file

    This could simply be done by importing your CSV into Excel

    Then filtering for the required Name, amend the time or as many entries as you need.

    Then convert back to a CSV

    Store the file back to the server.

    Easier and more versatile?

+ Reply to Thread

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