+ Reply to Thread
Results 1 to 3 of 3

if cell equals a certain lengh replace contents

  1. #1
    Forum Contributor
    Join Date
    01-16-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    136

    if cell equals a certain lengh replace contents

    Hi

    Is it possible to loop through a column of data and look for cells that cantains a value that has a lengh of 6 if found add a 0 in frotn of the current value. So 999999 would change to 0999999.

    James

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: if cell equals a certain lengh replace contents

    Sure, do it in a standard loop.
    But be warned, that it is a number and excel would (at first opportunity) try to treat this as number (not as text). going bact to your 6 digits.
    So make sure that a cell has text format (neithor geberal nor number would do).
    Best Regards,

    Kaper

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: if cell equals a certain lengh replace contents

    I would recommend simply reformatting the column to a CUSTOM number format of "0000000". This will ensure all real numbers in that column display with 7-digits, it will add leading zeros for you in the display of those cells.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Find and Replace the contents of one cell with the contents of another
    By thechevs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-30-2014, 06:48 AM
  2. If cell equals another cell from another worksheet then replace whole row
    By Psychoterapeuta in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2013, 11:22 PM
  3. Find and replace in a column and delete row if cell equals x
    By blzalewski in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2008, 03:47 PM
  4. [SOLVED] replace cell contents
    By Nancy B in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-16-2005, 01:06 PM
  5. How do I replace the contents of a cell with its value instead of.
    By Jean in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-03-2005, 05:06 PM

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