+ Reply to Thread
Results 1 to 5 of 5

replace first character of cell content

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    replace first character of cell content

    Hello!

    I am using a macro to copy, sort, format and delete some data which I pull from a textfile. however, some data (text only) starts with a "-" sometimes which was originally thought to help sort the data in the system from where the data originally comes from. Now when I import the columns to excel, I have the problem that excel understands the "-" as a formula and echoes me a #NAME error for that cell, which causes the macro to stop while processing it and leaves unfinished.

    So, could someone maybe please provide me some code which helps me to check all cells in a certain range if any is starting with a "-" and if yes, replaces it with a " ' " or something else which is acceptable for excel?

    thank you very much for the help!
    A2k

  2. #2
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: replace first character of cell content

    Add this code at the end of ur macros

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Re: replace first character of cell content

    well, i do know about the search and replace function (and actually have this in use at the moment) but the data also has several "-" later in the cell content, which I dont really like to replace. It would have to be strictly the FIRST character of the cell content which should be replaced.

    Thanks,
    A2k

  4. #4
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: replace first character of cell content

    Quote Originally Posted by Armitage2k View Post
    well, i do know about the search and replace function (and actually have this in use at the moment) but the data also has several "-" later in the cell content, which I dont really like to replace. It would have to be strictly the FIRST character of the cell content which should be replaced.

    Thanks,
    A2k

    Actually the above code is replacing the - when it is the first character .. see what := "=-" so, it is not just finding - but it is finding =- ( equal and hyphen combination)
    Last edited by Shijesh Kumar; 09-26-2009 at 07:26 AM.

  5. #5
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Re: replace first character of cell content

    how could I even dare to doubt you

    thanks for the help!
    A2k

+ 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