+ Reply to Thread
Results 1 to 4 of 4

Inserting specific text to specific position crossed with IF Formula

  1. #1
    Registered User
    Join Date
    03-18-2020
    Location
    Dallas, USA
    MS-Off Ver
    2020
    Posts
    38

    Inserting specific text to specific position crossed with IF Formula

    HI Team,

    I have a series of numbers from C1 to C500 that start in cell D2.
    Issue is I am trying to run a formula that has the logic:

    If there are less and 4 characters in this cell then add "0" after the 1st character and replace the second to fourth characters after the newly inserted "0"

    Example:

    C33 - formula identifies it has less than 4 characters.
    Formula then inserts a 0 after the first character: C0
    and then replaces the remainin characters after the newly inserted character: C033.

    Technically, the logic is possible via several different formulas and this is where i got to in regards to construction:

    =IF(LEN(D2)<4),(LEFT(D2,1) & "0" MID(D2,2,4)),D2) or =IF(ISNUMBER(SEARCH("TRUE",D2)Left(D2,1) & "0" & MID(D2,2,4)

    They obviously do not work as of yet.

    But separately they do. I have 3 formulas. The IF formula to identifty true/false. =LEN formula to identify if a cell has less than X amount of characters and =LEFT(D2,1) & "0" & MID(D2,2,4) which inserts the "0" where i need it to go.

    =IF function obviously works based on true and false statements which logically means =LEN(D2)<4 should be able to work alongside it.
    Furthermore, if I can identify an If True, then it should be able to be coupled with the 3rd formula to say if true then insert character here.

    Lastly, if false the cell should be left alone.
    So if I had C223 and applied the formula it would be left a C223 for example.
    Last edited by TSACov; 07-29-2020 at 12:17 PM.
    Thanks!
    - TSACov

  2. #2
    Registered User
    Join Date
    05-14-2020
    Location
    Mauritius
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Inserting specific text to specific position crossed with IF Formula

    Hello,

    your first formula works. You are just setting too many brackets:
    =IF(LEN(D2)<4,LEFT(D2,1)&"0"&MID(D2,2,4),D2)
    Greetings

    Tor


  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,459

    Re: Inserting specific text to specific position crossed with IF Formula

    Push the number into format "000" by TEXT function

    =LEFT(D2)&TEXT(MID(D2,2,3),"000")
    Quang PT

  4. #4
    Registered User
    Join Date
    03-18-2020
    Location
    Dallas, USA
    MS-Off Ver
    2020
    Posts
    38

    Re: Inserting specific text to specific position crossed with IF Formula

    Awesome! Thank you!!
    It's nice to know I was almost right haha!

+ 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. Replies: 6
    Last Post: 02-28-2017, 06:21 PM
  2. Retrieving rows containing specific text at a particular position
    By patwary8 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2016, 02:04 AM
  3. Replies: 3
    Last Post: 09-07-2014, 12:25 AM
  4. [SOLVED] Position of Last Specific Text Item in a Column
    By SDruley in forum Excel General
    Replies: 5
    Last Post: 03-08-2013, 11:39 PM
  5. Replies: 3
    Last Post: 06-20-2012, 07:16 AM
  6. Replies: 4
    Last Post: 09-06-2011, 10:36 AM
  7. Replace specific character in specific position
    By BMR in forum Excel General
    Replies: 4
    Last Post: 07-22-2011, 10:51 AM

Tags for this Thread

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