+ Reply to Thread
Results 1 to 5 of 5

If the first digit equal 7 then replace with a 6 otherwise return value

  1. #1
    Registered User
    Join Date
    09-04-2014
    Location
    london
    MS-Off Ver
    2010
    Posts
    2

    If the first digit equal 7 then replace with a 6 otherwise return value

    Hi,

    I hope someone can help answer this question.

    I have data in column A like below. I want column B to look at each cell from column A. If the fist digit is a 7 replace it with a 6. If not do nothing. So the result should be as in the right hand side (B)?

    A B
    33109 33109
    33419 33419
    77003 67003
    62276 62276
    33653 33653
    77001 67001
    62281 62281
    77078 67078
    65992 65992


    Thanks

  2. #2
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: If the first digit equal 7 then replace with a 6 otherwise return value

    Quote Originally Posted by Whu005 View Post
    I have data in column A like below. I want column B to look at each cell from column A. If the fist digit is a 7 replace it with a 6. If not do nothing. So the result should be as in the right hand side (B)?
    A B
    33109 33109
    33419 33419
    77003 67003
    [....]
    =IF(LEFT(A1,1)<>"7",A1,--("6" & MID(A1,2,99)))

    Note: I assume that A1 is numeric. If it is text, omit the double-negative operation (--).

  3. #3
    Registered User
    Join Date
    01-04-2013
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    66

    Re: If the first digit equal 7 then replace with a 6 otherwise return value

    Hi try this in b1 and past down

    =IF(INT(LEFT(A1,1))=7,INT(6&RIGHT(A1,4)),A1)

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: If the first digit equal 7 then replace with a 6 otherwise return value

    Another...

    Assuming your number is in A2, then
    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  5. #5
    Registered User
    Join Date
    09-04-2014
    Location
    london
    MS-Off Ver
    2010
    Posts
    2

    Re: If the first digit equal 7 then replace with a 6 otherwise return value

    Hi,

    Thank you all that was perfect. Works great.


    Cheers

+ 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. Replace all one-digit number with two-digit numbers
    By sandykunaish in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2013, 09:56 AM
  2. [SOLVED] How to replace a certain digit using VBA code
    By Shishek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2013, 08:47 AM
  3. Replace first digit with a different digit??
    By taimysho0 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-01-2012, 05:46 PM
  4. 5 digit numbers where the sum is equal to 18
    By MomMel in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 01-19-2011, 11:23 AM
  5. How to replace the last digit in a cell with a letter
    By bramruis via OfficeKB.com in forum Excel General
    Replies: 16
    Last Post: 11-14-2005, 09:45 AM

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